It is a language for easily manipulating text, files and processes. Structurally it looks quite a lot like C , it has the curly brackets and similar conditional operators. It also has powerful text manipulation features through the use of regular expressions which though confusing at first are pretty damned useful for script processing.
#!/usr/local/bin/perl require "www_lib.pl"; #include the perl library $my_url=&get_this_URL(); #find out what the current URL is %MYPAIRS=&PARSEFORM(); #get the pairsThe
PARSEFORM
sub-routine ensures that no shell-escapes are
received by the processing part of your script and splits the input
into and associative array that contains name,value pairs.
@fields=keys %MYPAIRS; if ( @fields == 0 ) { # no fields were present which means this is the display part &show_front_page; } else { # fields were present ,decide on what to do if ($MYPAIRS{'button1'}) { # processing when button1 is pressed } elsif ($MYPAIRS{'button2'}) { # processing when button2 is pressed } # # etc and so on # else { # exhausted all other possibilities, bad input } } exit;The
input_key
is the name of a field on your form
that determines what processing occurs. If your form contains
several buttons each with a different action you can use the name
of the button to decide what the script should do.
sub show_front_page { &PRINT_HEADER("title",""); print " <form method=POST action=\"$my_url\"> [the inputs that make up your form go here] </form>"; &PRINT_FOOTER; }The
$my_url
variable stores the url the user sees
for the script. Using it in the ACTION
allows the
script to re-use itself for processing.
There are many varied ways of doing this, most involve the use of full text database engines to index all the unique words in your documents so that the documents that they are in can be readily retrieved.
You could use