in reply to Perl obeys Star Trek trivia

For the baffled, let me explain. The -p switch physically adds code around your code.
# perl -pe CODE

while (<>) {
  CODE;
} continue {
  print or die qq(-p destination: $!\n);
}
with the exception that there's minimal whitespace. So if CODE is print q, you end up printing print or die qq(-p destination: $!\n), the length of which is 47 characters.

_____________________________________________________
Jeff[japhy]Pinyan: Perl, regex, and perl hacker.
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

Replies are listed 'Best First'.
Re: Re: Perl obeys Star Trek trivia
by blakem (Monsignor) on Dec 04, 2001 at 07:22 UTC
    So, the ';' is being used as the delimiter for q...
    q;}continue ... $!\n);
    Very strange indeed, I thought the closing bracket was the delimiter and thus was quite confused. So, not only does it physically wrap your code in a while loop, it adds an unnecessary semicolon before the end of the block. Or at least thats what it looks like to me....

    Oh, in last Friday's golf, chipmunk had a one-liner entry that (ab)used this "physical" wrapping feature of -p (well -n really) for those that want another data point to play with.

    -Blake