Anarion has asked for the wisdom of the Perl Monks concerning the following question:

I was plating recently with eval .. i just wonder how this
works.

perl -e '$_="s//s!!A!/e";eval;print'


$anarion=\$anarion;

s==q^QBY_^=,$_^=$[x7,print

Replies are listed 'Best First'.
Re: A Simple question
by japhy (Canon) on Sep 04, 2001 at 01:59 UTC
    Don't modify the string you're modifying in a substitution. That's deep (broken) magic.

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

      Do you know why it prints: "11@p @" ?


      $anarion=\$anarion;

      s==q^QBY_^=,$_^=$[x7,print

        I have absolutely no idea - no surprises there - but to my delight, when I run it it prints

        11 fO&vO/e

        .. except that instead of 'O' I get one of those machine code emoticons that I would render with <font face="wingdings">K</font> except I can't owing to circs beyond my control. I find this pleasantly inexplicable. Someone must know what's going on, and I'd love to know what.

        § George Sherston