in reply to Multi-roled colon

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

Replies are listed 'Best First'.
Re: Re: Multi-roled colon
by Anonymous Monk on Oct 02, 2003 at 08:25 UTC
    Now that's longwinded ;)
    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