in reply to Just another japh

Very, very cool. One step in particular had me going for a while... Read more for spoilers.
# This is one big regex which sets # $_ = ",:_,,},,],,_:){:"},,:,,,,,_,:(,:,,,(:){,,{,:,,,(,:[:){,:(:"}:" +",:},:,,,(" s;;,:_,,},,],,_:){:"},,:,,,,,_,:(,:,,,(:){,,{,:,,,(,:[:){,:(:"}:"",:}, +:,,,(;; # This translates individual characters, e.g., all ',' in $_ become 'P +'. # $_ = "PQWPPVPPTPPWQRSQXVPPQPPPPPWPQUPQPPPUQRSPPSPQPPPUPQYQRSPQUQXVQX +XPQVPQPPPU" y;,:_}][{"();PQWVTYSXUR;; # This is the step that had me confused. # It takes each individual character and xors it with 'a'. For example +: # a (ASCII 97) xor P (ASCII 80) is ASCII 49 ('1') # Now $_ = "1061171151160320971101111161041011140321121011141080321040 +97099107101114" s;(.);a^$1;eg; # This takes each group of three and prints out their chr(); e.g., 106 + becomes chr(106) = 'j' # now $_ = "just another perl hacker" s!(...)!chr$1!eg; # Append a newline and print $_.=$/; print;

Replies are listed 'Best First'.
Re: Re: Just another japh
by physi (Friar) on May 08, 2003 at 09:03 UTC
    Nice,
    now I know why it works :-)

    There was a problem, when I've done the tr part. In my first attempt I was using:

    y;PQWVTYSXUR;,:_}][{}();;
    instead of
    y;PQWVTYSXUR;,:_}][{"();;
    But that gaves a strange result:

    Try this little script:

    s;;PQWPPVPPTPPWQRSQXVPPQPPPPPWPQUPQPPPUQRSPPSPQPPPUPQYQRSPQUQXVQXXPQVP +QPPPU;; print $_.$/; y;PQWVTYSXUR;,:_}][{}();; y;,:_}][{}();PQWVTYSXUR;; print $_.$/;
    This should normaly print out 2 equal strings. But it doesn't!? All the 'X' in the first string are replaced by a 'V'!?
    I've got no idea why!

    Cheers, physi

    -----------------------------------
    --the good, the bad and the physi--
    -----------------------------------
    
      y;PQWVTYSXUR;,:_}][{}();; y;,:_}][{}();PQWVTYSXUR;;
      As you might know by now: You used } twice in your replacement string. So no wonder it fails.
        8-}
        Thanks, for that hint ;-)

        -----------------------------------
        --the good, the bad and the physi--
        -----------------------------------