I have seen alot of post's on this BBS that ask "what is the best
scripting lang to learn" I once asked myself the same thing.Rather then
telling you what I believe.I think the best way to do this is
to show you.Because I fell as A human we were given the right to make of own decisions.
so let goooo.

my fav scripting language perl.
PERL is a powerful language that has similar syntax as c
because i was writes in c.now lets get our hand's dirty.
all you elites out there don't hate on me because I decided
to start with the "hello world" programs.
(this is not the best way to program but i have decided this might be the
best way to show you)


code:--------------------------------------------------------------------------------
$string = "hello world"; #comments are started with the sign "#"
#perl uses "$" for its variables

print "$string"; #this print to the screen the string
#"hello world"

--------------------------------------------------------------------------------

perl also is very good with html. lets make the simple program display
html so you use it for the web.

code:--------------------------------------------------------------------------------
#!/usr/local/bin/perl #this line is very important
#it points the program to the
#perl interpreter you might have to
#change depending on the system that you use

$string = "hello world";

print "<html><head><title>";
print "simple program";
print "</title></head>";
print "<body>$string</body>";
print "</html>";
--------------------------------------------------------------------------------


If you upload this file use the .pl or .cgi file exstention with the permission of 0755(for scripts you want to exicute use 0755 and 0644 for lib and log files) and place it in a working "cgi-bin"
I wont get to deep into permissions at this time.but basically this means that
you as the owner of the file can read write and execute the code but everybody else can just
read and execute it.
PERL is also great for math.lets take a look at simple math script.

code:--------------------------------------------------------------------------------
#!/usr/local/bin/perl

$sales_for_00 = 2000;
$sales_for_99 = 2043;
$total_sales = $sales_for_00 + $sales_for_99;

print "$total_sales";
--------------------------------------------------------------------------------

I know this is a very basic math script but you get the Idea.
PERL is great for matching strings and replacing them with whatever you want.
lets just say you put up a site and you wanted to make sure that the visiters
dont enter a "*" or any other potentailly dangerious charicters.You could write
a program to take them out

code:--------------------------------------------------------------------------------
!#/usr/local/bin/perl
require "sub.lib";
&parse_form;
$name = $formdata{'name'};
$email = $formdata{'email'};
$comment = $formdata{'comment'};

$name =~ tr/*/ /g;
$email =~ tr/*/ /g;
$comments =~ tr/*/ /g;
print "content-type: text/html\n\n";
print "this program takes out the "*" in\n";
print "the name, email, and comment's and replaces\n";
print "them with " " using the powerfull tr///; (trade) funtion\n";
--------------------------------------------------------------------------------

you can trade (tr/// substatute (s/// or match (m/// string's in perl.I think that this is one of the great funtions in PERL.
Perl is good for logging vistiters if you need to for whatever reason.
perl uses the $ENV{'<some_variable>'}; to get the enviromemt infomation they need.
lets take a look.

code:--------------------------------------------------------------------------------
#!/usr/local/bin/perl

$log_file = "/data/log.txt"; #sets the text file to use
$name = $ENV{'REMOTE_NAME'}; #gets name of the visiters
$ip = $ENV{'REMOTE_ADDR'}; #gets ip of visiters
$browser = $ENV{'HTTP_USER_AGENT'}; #gets the browser used
#now let's write this to file for later viewing
OPEN(LOG,">>$log_file") || &errorfile; #this line opens the log file
flock(LOG, 2); #and the ">>" appends the file
print LOG "$name|$ip|$browser\n"; #the flock funtion stops the use of #the script by more then
flock(LOG, 8); #one person at a time
CLOSE (LOG);

sub errorfile {
print "content-type: text/html\n\n";
print "could not open file";
}
--------------------------------------------------------------------------------

now for my favorite part of PERL is great for processing text vie a form.If you don't know about form here is a crash course.

code:--------------------------------------------------------------------------------
<html>
<head>
<title>
simple form
</title>
</head>
<body>
<form name=form method=post action="form.cgi">
Name:<input type=text name=name>

email:<input type=text name=email>

<input type=submit value=submit>
</form>
</body>
</html>
--------------------------------------------------------------------------------


ok now that we have a form we can save the the form as ooooohh "form.html"
next we will need a script to process the info
don't be upset if this is to much for you right now
this script uses alot of PERL funtion's
and progrmming tricks

code:--------------------------------------------------------------------------------
sub parse_form {
if ($ENV{'REQUEST_METHOD'} eq 'get') {
@pairs = split(/&/,$ENV{'QUERY_STRING'});

}

elsif ($ENV{'REQUEST_METHOD'} eq 'post') {
read (STDIN, $buffer ,$ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);

if ($ENV{'QUERY_STRING'}) {
@getpairs = split(/&/, $ENV{'QUERY_STRING'});
push(@pairs,@getpairs);

}

else {

print("content-type: text/html\n\n");
print("use post or get ");

}

foreach $pair (@pairs) {
($key, $value) = split(/=/, $pair);
$key =~ tr/+/ /;
$key =~ s/%(..)/pack("c", hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%(..)/pack("c", hex($1))/eg;
$value =~ s// /g;


if ($formdata{$key}) {
$formdata{$key} .= ", $value";

}

else {
$formdata{$key} = $value;

}
}
}
1;
--------------------------------------------------------------------------------

alot of code I know but the good thing is once you have this code you can use it from site to site.So save this in a file called sub.lib with the permission of "0644". next lets finish this program.Next we will need to write a script that will display the infomation.take a deep breath
its not as bad as the last code.

code:--------------------------------------------------------------------------------
#!/usr/local/bin/perl
require "sub.lib"; #calls the file for use in this script
&parse_form; #this calls the sub to decode the text

print "Content-type: text/html\n\n";

foreach $key (key %formdata) {
print "You have Entered $formdata{$key} in the $key field";
}

#this print the information that was Entered and displays it
--------------------------------------------------------------------------------

well thats it for now.IF anything I hope this will push you into perl,or some other language.This information is not to take the place of a good book.I have studied PERL for 2 years and let me tell you that I have a long way to go.Perl is a big language not to mention the writer's of PERL is working with the writer's of PYTHON so its just going to get bigger and better...but nothing a lot of coffee and time wont fix.