ServersReview Page 6

Review Page 6

ServerWatch content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More.




To review what we have learned, let’s start again, briefly, at the beginning. We learned how to FTP a program to the server and how to set the appropriate permissions. We learned that the first line of our program needs to point to the location of the Perl interpreter. We learned what a comment is, how to use them, and the correct syntax (Start a line with # followed by your comment). We learned about scalar variables, their syntax, and how to correctly edit them. We learned the difference between server paths and URLs. We learned that a subroutine is a block of code that completes a specific task when called. The correct syntax would be something like this:

s

&GetDrink # Call Subroutine

s

sub GetDrink { #The Actual subroutine
print “I am thirsty”;
} #End subroutine

s

Every time we called the subroutine now in our program we would print the line “I am thirsty.” We learned about query strings and simple pattern matching in Perl.

s

if ($something =~ /exec/i) #matches for a non case sensitive regular expression containing the
# letters exec.

s

if($something_else eq “exec”) #matches strictly for the word exec, case sensitive

s

We learned how to open and close a file using a file handle, and the three ways to modify the file:

s

open(FILE1,”$FileName”); # Opens as read-only
open(FILE2,”>>$FileName”); # Opens for appending
open(FILE3,”>$FileName”); # Opens for writing (deleting previous contents)

s

It would be relatively simple to write a program that would parse our text file and tell us each user’s progression through the Web site. It would also tell us how long they spent on each page and what kind of browser they were using. It would function as a limited statistics package collecting some very useful information. If nothing else, remember that it’s a “Perl-fect” world!

Get the Free Newsletter!

Subscribe to Daily Tech Insider for top news, trends & analysis

Latest Posts

Related Stories