#!/usr/bin/perl -w just another perl hacker
print+seek(DATA,$=*.3,@-)?scalar<DATA>:$:__DATA__
Short enough to fit in a .sig, no semicolon, no space, only three functions used (if anybody knows a trick how to force scalar context without using scalar, please let me know)

And, above all, Deparse-save!

BTW, should't be too hard to de-obfuscate ...(I'll post a solution in a few days, if nobody (could/cared to) solve it.

It also runs under use strict, but then I'd had to add a semicolon, which I didn't want to use here.

Replies are listed 'Best First'.
Re: seek and ye shall find
by BeernuT (Pilgrim) on Mar 07, 2002 at 14:22 UTC
    Look at using ~~ for forcing scalar context:
    #!/usr/bin/perl -w just another perl hacker print+seek(DATA,$=*.3,@-)?~~<DATA>:$:__DATA__


    -bn
      Thanks! Just applied this to my new .sig
Solution(?): seek and ye shall find
by Dog and Pony (Priest) on Mar 07, 2002 at 15:00 UTC
    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.
      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.

      The thing is that if you use __DATA__, perl automatically seeks to the beginning of the DATA-section. But at the same time it sets the DATA-filehandle to the current file, so if you seek it yourself, you actually seek the source code itself.

      I learned this from TheDamians SelfGOL.

      And BTW, your solution is correct (and very well written, IMO)

      The only thing worth mentioning is that
      seek+print
      is actually the same as
      seek print
      as the + is used as the unary plus in front of a term, basically having no effect on anything.

      --
      #!/usr/bin/perl -w just another perl hacker
      print+seek(DATA,$=*.3,@-)?~~<DATA>:$:__DATA__
      
        Isn't this rather print+seek instead of seek+print ?

        -= Bobinours =-