in reply to Removing chars from a word from an array
Hi,
I dont know whether i understood your question correctly. If im not wrong what you need is to delete a set of characters from a word. But a character has to be removed only once in the word and has to be removed from @list.
use strict; use warnings; my @list= qw(a b c a c); my $w="kandabbbc"; while (my $a=shift(@list)) { $w=~s/\Q$a//; @list = grep {!/\Q$a/} @list; } print $w;
If you want to remove all the occurances of a character from the word, then
use strict; use warnings; my @list= qw(a b c a c); my $re = join '|', @list; my $w="kandabbbc"; $w=~s/$re//g; print $w;
Regards,
Murugesan Kandasamy
use perl for(;;);
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Removing chars from a word from an array
by blazar (Canon) on Jan 24, 2006 at 16:20 UTC |
In Section
Seekers of Perl Wisdom