This pales when compared to some of the nightmare code that graces these pages, but coming from a C background, doing anything in 2 lines is a foolish dream.

($o,$_)=([' isn\'t',' is'," a palindrome.\n"],shift); print $_,map{$o->[$_]}($_ eq join"",reverse/(\w)/g),2

Replies are listed 'Best First'.
RE: aoxomoxoa
by Adam (Vicar) on Jul 14, 2000 at 01:09 UTC
    Y:\>perl -we "($o,$_)=([' isn\'t',' is',qq! a palindrome.\n!],shift); print $_,map{$o->[$_]}($_ eq join qq!!,reverse/(\w)/g),2" Use of uninitialized value in pattern match (m//) at -e line 1. Use of uninitialized value in string eq at -e line 1. Use of uninitialized value in print at -e line 1. is a palindrome.
      For those who think that Perl lacks the adequacy to replace english
      I will attempt to translate and answer this:
      
      perl -we "code........." = when I executed this from the commandline it didn't work.
      
      note: shift is regularly used in programs, replace shift with "palindrome word" 
      (obviously replace "palindrome word" with the word you are testing.)
      
      If no word is applied the program will not work as is expected.
      
      Using -w does NOT mean something is wrong : try this if ( int ("") < 0) {print "foo.\n"}
      with -w it whines, this is a valid way of converting strings to integer.
      and it converts the value to 0 but still it complains. Perlease....
      
      The script is just showing that in one line you can find a palindrome
      That is how cool Perl is. 
      
      The wrapping code lacks validation and prettification, as I expect the 
      perl community to understand the spirit in which this is posted.
      

      If I wanted to write bullet-proof code, I would do it in three lines not two!!</emp>

      
      Frankus.
      
        Well, obfuscated code is meant to be a showcase, and it's far more impressive if your code works with warnings and strict. Plus, I'd still do it in two lines:
        $_=$ARGV[0]||die;my$x="$_ is ";$x.="not "if($_ ne join"",reverse split//);print $x," a palindrome";
        (If the errors were helpful, it wouldn't be obfuscated, now, would it?)

        Andrew.