Hmm... very nice. You just taught me something I didn't know about <DATA>. :) Namely that the position of it, as returned by tell, seems to be counted from the start of the file it is in. And that seems to be the solution to the puzzle too.
#!/usr/bin/perl -w just another perl hacker
The part after perl -w that are not switches are simply ignored, moving us to the next line.

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. :)


You have moved into a dark place.
It is pitch black. You are likely to be eaten by a grue.

In reply to Solution(?): seek and ye shall find by Dog and Pony
in thread seek and ye shall find by domm

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.