in reply to Re: Chop command that removes the first character
in thread Chop command that removes the first character

To complete the theme: sub chimp (@) { s!^$/+!! for @_ }

Replies are listed 'Best First'.
Re^3: Chop command that removes the first character
by BrowserUk (Patriarch) on Oct 26, 2004 at 10:26 UTC

    Ooh! Ooh! Ooh! :)


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail
    "Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon
Re^3: Chop command that removes the first character
by Anonymous Monk on Oct 26, 2004 at 14:51 UTC
    sub chimp (@) {s!^$/+!! for (@_ ? @_ : $_)}

      Now get that included in CORE, surely it belongs in the (development) tree.

Re^3: Chop command that removes the first character
by ihb (Deacon) on Mar 10, 2005 at 12:49 UTC

    chomp() does not remove all trailing record separators, just one. The special case is paragraph mode where all trailing newlines are removed. When in fixed-length record mode ($/ = \$some_int) or slurp mode ($/ = undef) chomp() does nothing. All these special cases aren't handled by &chimp.

    Also, the return value isn't analoguous with chomp()'s.

    ihb

    See perltoc if you don't know which perldoc to read!