perl -we \ 'print((split//,"\nechle etn sJutaohrPr akr")\ [map{splice @_,@_/$^F,$^W}(@_=$%..$^F*$=/5)])'
Depends on array slicing, order of evaluation, using the same variable in two different contexts, implied iteration via .. and map, a null split, and default values of special variables. Don't forget the -w.

Replies are listed 'Best First'.
Re: Splicing and slicing
by diotalevi (Canon) on Apr 14, 2003 at 16:55 UTC

    Its also dependent on your shell's idea of which characters are special. I use ksh and get a syntax error. Can you repost that as something that doesn't depend on your shell?

    $ perl -we \ > 'print((split//,"\nechle etn sJutaohrPr akr")\ > [map{splice @_,@_/$^F,$^W}(@_=$%..$^F*$=/5)])' Backslash found where operator expected at -e line 1, near ")\" (Missing operator before \?) syntax error at -e line 1, near ")\" Execution of -e aborted due to compilation errors.

    nevermind - here's a version that actually works

    #!/usr/bin/perl -w print((split//,"\nechle etn sJutaohrPr akr") [map{splice @_,@_/$^F,$^W}(@_=$%..$^F*$=/5)])
Re: Splicing and slicing
by Mr. Muskrat (Canon) on Apr 14, 2003 at 16:59 UTC

    Oopsie!

    Microsoft(R) Windows 98 (C)Copyright Microsoft Corp 1981-1998. C:\WINDOWS\Desktop>perl index.pl Backslash found where operator expected at index.pl line 1, near "we \ +" (Do you need to predeclare we?) syntax error at index.pl line 1, near "we \" Execution of index.pl aborted due to compilation errors.

Re: Splicing and slicing
by allolex (Curate) on Apr 15, 2003 at 07:13 UTC

    Geez, you guys...

    perl -we 'print((split//,"\nechle etn sJutaohrPr akr") [map{splice @_, +@_/$^F,$^W}(@_=$%..$^F*$=/5)])'

    --
    Allolex