I Write Funny Comments

DarkKnightRadick on 2003-06-28T16:00:48

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!