in reply to howto strip the first char of a string?

substr $_, 0, 1 = "";
or substr $_, 0, 1, "";

Replies are listed 'Best First'.
Re^2: howto strip the first char of a string?
by Random_Walk (Prior) on Sep 09, 2004 at 07:34 UTC

    The first of these does not work for me (at least on perl 5.005_03) The second is cunning enough though.

    perl -lpe 'substr $_, 0, 1 = "";' Can't modify constant item in scalar assignment at -e line 1, near """ +;" Execution of -e aborted due to compilation errors. perl -lpe 'substr $_, 0, 1, "";' this is his is
    The first one will work with a minor tweak
    perl -lpe 'substr($_, 0, 1) = "" ' test est

    Cheers,
    R.