in reply to Re: Chomping Frenzy question
in thread Chomping Frenzy question

$s =~ y/*+!//d;

This would replace all the characters in $s, not only those in the end, and it would replace them in any sequence - so this is not useable in my situation.

-- 
Ronald Fischer <ynnor@mm.st>

Replies are listed 'Best First'.
Re^3: Chomping Frenzy question
by linuxer (Curate) on Jul 10, 2008 at 19:32 UTC
    $s =~ y/*+!//d;
    This would replace all the characters in $s, not only those in the end, and it would replace them in any sequence - so this is not useable in my situation.

    No, it wouldn't (remove any character).
    It removes any occurence of the characters '*', '+' and '!' (it's a use of the transliterate operator tr/// (same as y///). It doesn't care about the position of the characters.

    $ perl -e 'my $s = "xyabcy*+!*+!*+!*+!*+!*+!"; $s =~ y/*+!//d; print +$s, $/;' xyabcy $ perl -e 'my $s = "*+!xyabcy*+!*+!*+!*+!*+!*+!"; $s =~ y/*+!//d; pri +nt $s, $/;' xyabcy $

    I don't think, that tr/// or y/// can help you with your chomp problem.

    update: minor changes in text (... remove any char...)

      It removes any occurence of the characters '*', '+' and '!'

      Yes, that's what I meant. Sorry for being unclear. In any case, this is not a solution for my original problem.

      -- 
      Ronald Fischer <ynnor@mm.st>