in reply to cut of first char of a string

First, but not last:
$_ = '12345';s/(.(.*))/$2or$1/e


Replies are listed 'Best First'.
Re^2: cut of first char of a string
by Anonymous Monk on Mar 08, 2005 at 13:47 UTC
    That doesn't work correctly:
    perl -wle '$_ = '10'; s/(.(.*))/$2or$1/e; print' 10
      Yes, that doesn't, but this does:
      s/(.(.*))/($2ne'')?$2:$1/e


        $_ = "a"; s/(.(.*))/($2ne'')?$2:$1/e; print
        That gives "a". I'd expect nothing to get printed - if I remove the first character of a one-character string, I should be left with the empty string, not with the same string.