The part after perl -w that are not switches are simply ignored, moving us to the next line.#!/usr/bin/perl -w just another perl hacker
print+seek(DATA,$=*.3,@-)?scalar<DATA>:$:__DATA__That is the magic part - it sets the file pointer of <DATA> to 18, counted from the start of the file, which puts the next read right after -w. Why 18? Because $= defaults to 60. Update:Forgot to mention that @- is the same as a zero, thus giving the third argument to seek that is needed.
The seek also succeeds, returning true so what happens is this:
print+seek(DATA,$=*.3,@-)?scalar<DATA>:$:__DATA__And forcing <DATA> to be printed in scalar mode makes it only print the first line - and there you go. :)
Side notes:
print+seek(DATA,$=*.3,@-)?scalar<DATA>:$:__DATA__$: is just a placeholder, or to throw us off, and it defaults to zero or an empty string (don't remember). The __DATA__ part is needed for this to work, otherwise perl will complain about an unopened filehandle.
Hope I didn't forget, or misunderstand anything. Correct me then, please. :) And thank you for teaching me something new. I think it is a very nice sig. :)
In reply to Solution(?): seek and ye shall find
by Dog and Pony
in thread seek and ye shall find
by domm
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |