|Keep It Simple, Stupid|
Re: Cooking with Perl explained by Iron Chef Macphistoby Macphisto (Hermit)
|on Jan 05, 2001 at 00:05 UTC||Need Help??|
Okay, Being that I talk to zdog and really respect his level of programming skill, I decided I'd explain how this one went because while it's somewhat simple, zdog was very creative with it and I like it more than most.
First we'll make it look more recognizable and throw in some quick commentary
Now for a line by line description:
Line 1-2 These are of course self explanatory
Line 3-6 This little construct will read all of <DATA> into $_ ending when DATA ends of course
Line 7 The regex here takes out all of the newlines, all the digits'3' and all any alpha numeric ( capital of course ). Which leaves us with the following string07411711511603209711011101161041011140320801011141000072097099107101114 ( hope I didn't miss any )
Line 8 Switches all 000's in the above string with 032
Line 9 Throw $_ into the array @z
Line 10-13 This for loops mercilessly hacks the digit string into sections of three digits. Giving us the following:
Line 14 Declares $z
Line 15 maps the character representation of each three digit piece into $z
Line 16 Adds a new line to $z and assigns it to $_
Line 17 Prints $_ and thus prints "Just Another Perl Hacker"
I was very impressed with this and hope my explination was adequate.
Iron Chef Macphisto
Next episode I'll show you how to make Perl Pie
Addendum: zdog noted that I had mistyped and said the for loop iterates 23 times when it really iterates 24 times. I was typing too fast.
Everyone has their demons....