Nifty.
Skip the first ':;' line. I wouldn't initially guess that a colon with a trailing semicolon and preceeding whitespace is "a line containing just a colon", but there you have it. ;) perlrun discusses replacing a shebang line with : in conjunction with the -S command line option, to start up 'sh' rather than 'csh' on some systems that don't recognize the #! line. The leading whitespace and trailing colon aren't explicitly discussed, and you would think that "line containing just a colon" precludes anything else being on the line. I suppose that looking at the verbage a couple of times I see where "...some systems may have to replace the #! line with a line containing just a colon, which will be politely ignored by Perl." really means that the entire line will be ignored.
Next, $: contains "\n-" normaly as the "Format Line Break Characters" special variable.
Next, $:=~s.... has an embeded newline, so it really looks like, $: =~ s/\n-/;another Perl Hacker /;
Next, chop $: removes the trailing space character.
Next, $: =~ y:;::d; is a funky way of saying, $: =~ tr/;//d, which deletes any ';' characters found. In this case, it's the leading ';' in ';another Perl Hacker'.
Next, print+Just.$:; or in other words, print 'Just' . $: ;, or in other words, print 'Just' . 'another Perl Hacker';
In this case, whitespace is definately relevant!
Dave
"If I had my life to do over again, I'd be a plumber." -- Albert Einstein
| [reply] [d/l] [select] |
perl -MO=Deparse -
:;$:=~s:
-:;another Perl Hacker
:;chop
$:;$:=~y
:;::d;print+Just.
$:;
__END__
$: =~ s/\n-/;another Perl Hacker\n /;
chop $:;
$: =~ tr/;//d;
print 'Just' . $:;
- syntax OK
| [reply] [d/l] |
Neat. Didn't know Perl doesn't mind a lone colon.
Makeshifts last the longest.
| [reply] |
Then you probably didn't know that that fact was actually
documented? See "man perlrun", in the section that talks
about the -S option. (It's amazing how many obscure Perl
syntax/semantics issues are actually documented).
Perl only ignores a lone colon if that
colon is the first non-whitespace character in a file though.
Abigail
| [reply] |
To wit, it says: ... a line containing just a colon, which will be politely ignored by Perl.
It takes a twisted mind genius to read that and turn it into an obfu. Well done Abigail-II!
| [reply] |
My first guess was that it (the lone colon) was Perl implementing the null operator from the bourne family of shells and I couldn't think of any reason why they would have done that... clearly because they hadn't *grin*
-- Do not seek to follow in the footsteps of the wise. Seek what they sought. -Basho
| [reply] |