Dr Manhattan has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks
I have an array full of words. Some of them ending with ,|?|! etc. I want to remove/substitute these charcters so words like 'what?' just becomes 'what'.
I tried this-
foreach my $word (@array) { $word =~ s/(\.|\?|\!)$//; } foreach my $word (@array) { print "$word\n"; }
but sadly it does not work
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: substitute within elements of array
by kcott (Archbishop) on Apr 09, 2013 at 10:18 UTC | |
Re: substitute within elements of array
by choroba (Cardinal) on Apr 09, 2013 at 09:24 UTC | |
Re: substitute within elements of array
by Anonymous Monk on Apr 09, 2013 at 09:26 UTC |
Back to
Seekers of Perl Wisdom