in reply to Perl's Bad Ideas

I'm surprised how few gripes this call for gripes generated, I guess we love our Perl, but I have one more. I don't wanna chomp no more. chomp $this; chomp $that; chomp; chomp; chomp; I'm tired of chomp. I wish for an autochomper.

YuckChomp

Replies are listed 'Best First'.
Re: Perl's Bad Ideas
by Dominus (Parson) on Apr 07, 2002 at 23:33 UTC
Re: Re: Perl's Bad Ideas
by belg4mit (Prior) on Apr 07, 2002 at 00:00 UTC
    Oh come now, you mean you don't do
    { local $/ = 'eatMe'; chomp($str); }
    What then?
    $str =~ s/eatMe$//;
    Or
    $str = substr($str, 0, rindex($str, 'eatMe'));
    Or
    $pat = 'eatMe'; substr($str, rindex($str, $pat), length($pat), '');
    Or ...

    Chop on the other hand is definitely chomp's evil twin brother. Admittedly I could probably use chomp more, though s/// occurs to me more readily. (It's so easy to whip out the 800 lb. gorilla).

    --
    perl -pe "s/\b;([st])/'\1/mg"