Branching Method

Saturday May 6th 2000 by Joe Burns
Share:

In this primer, we'll play with the PERL branching method.

OK, at this point, we've broken down the guestbook script line by line. Over the next two primers, we're going to alter it. In this one, we'll play with the PERL branching method. In the next primer, we post the results to another page. Neither event is overly hard, but let's go through it slowly so I'm sure you'll understand it.

First off, here's the script in action. Try it a couple of times, each time choosing a different answer or no answer at all to the newsletter radio buttons.

Branching Guestbook Example

We'll start with the new guestbook HTML code. You'll notice it's exactly the same as the last primer except I stuck in a couple of radio buttons asking of the user wants to subscribe to our newsletter or not.

The New Guestbook Branch HTML Code

Here is the new script we're going to be working on. Again, the code in dark blue is the code that is new to the script from the last primer. If you know any JavaScript, this will look somewhat familiar to you.

The Branching PERL Guestbook Script

There's no need to change any modifications at this time. If you upload the files to replace what you have up there, then the modifications will just remain on the file. If you rename this pup and upload it, then yes, you need to set the modifications on the new files you uploaded, 775 for the CGI and 644 for the HTML page.

Got it? Seen it? Did you scroll all the way down the script? Are there two new blocks of code? Both are blue. Look again if you didn't see them.

PERL Branching Code