Well I'm back to trying to push Perl into my brain, I've got out my Learning Perl book and links to several CD Bookshelves online so I have plenty of resources to go to, I just hope I can sucessfully get past hashes this time. Right now though I'm going to go play some games. Or metamoderate on SlashCode or here on usePerl.
I've not done much with Perl lately. Been focusing on PHP/MySQL at the moment, although I did write a perl script that calls up a specific fortune file and uses it as a 404 error page. You can't even tell that I'm calling a CGI either, it's fairly cool that way. I'm thinking of using some absolute URLs to spiffy up the error document, perhaps by adding a picture or something.
I do have a directory full of images that I could also pull up with my script and have displayed. I grabbed them from the Duke3D guys. They have some wacky 404 error images.
Um, okay, that's it.
I write funny comments in my Perl programs.
#!/usr/bin/perl -w
#mmmm....pi
$circumfrence = 2 * 3.141592654;
$radius = 12.5;
print $circumfrence * $radius . "\n";
#!/usr/bin/perl -w
#pi good
$circumfrence = 2 * 3.141592654;
chomp($radius = );
print $circumfrence * $radius . "\n";
#!/usr/bin/perl -w
#When come back, bring pi
$circumfrence = 2 * 3.141592654;
chomp($radius = );
$circle = $circumfrence * $radius;
if ($radius 0) {
print "The radius of the circle is 0\n";
} else {
print $circle . " is the radius of the cirlce\n";
}
#!/usr/bin/perl -w
#I have a feeling the answer will be 42
print "I have a feeling the answer will be 42!\n";
print "Please input the first number:";
$first_num =;
print "Please input the second number:";
$second_num = ;
$answer = $first_num * $second_num;
if ($answer != 42) {
print "Actually, the answer is $answer\n";
} else {
print "See! The answer is 42!\n";
}
#!/usr/bin/perl -w
#So, how many towels do you have?
print "Please enter a word here: ";
$name = ;
print "Please enter a number here: ";
$number = ;
print $name x $number;
#!/usr/bin/perl -w
#Hard coded math action!
print 2 + 3 x 100 * 3 . "\n" . "\t" x2 . 5 * 4 x 20 . "\n";
$math = 2 + 3 x 100;
$multiply = $math * 3;
print $multiply . "\n" . "\t" x 2 . 5 * 4 x 20 . "\n";
#More Chapter 2 Coding goodness!
chomp($name = alex);
if ($name gt 'fred') {
print "'$name' comes after 'fred in sorted order.\n";
} else {
print "'$name' does not come after 'fred'.\n";
print "Maybe it's the same string, in fact.\n";
}
#Shorter example?
$is_bigger = $name gt 'fred';
if ($is_bigger) { print "'$name' is greater than 'fred'.\n"; }
#Doing the opposite!
if (! $is_bigger) {
print "You idiot, '$name' isn't even close!\n";
}
#taking standard input!
$line = ;
if ($line eq "\n") {
print "That was just a blank line!\n";
} else {
print "That line of input was: $line";
}
#An example of chomp!
#Commented out to show refinement
#$text = "a line of text\n";
#chomp($text);
#print $text;
chomp($text = );
print $text;
#while we were out...
$count = 0;
while ($count 10) {
$count += 1;
print "The count is now $count\n";
}
#undef, you are nothing to me.
$n = 1;
while ($n 10) {
$sum += $n;
$n +=2;
}
print "The total was $sum.\n";
#Lady Madonna, child processes at her feet!
$madonna = ;
if ( defined($madonna) ) {
print "The input was $madonna";
} else {
print "No input available!\n";
}
Tomorrow I begin Lists and Arrays!