Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
can you suggest a best methods!.use strict; use warnings; my $string = "aabbzzb"; my $oldchars = "ab"; my $newchars = "xx"; $_ = $string; #replace the chars by "x" char. eval "tr/$oldchars/$newchars/, 1" or die $@; $string = $_; #then delete the 'x' char. $string =~ tr/x//d; print $string; #will print zz
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: deleting characters from a string but the characters are in a variable
by moritz (Cardinal) on Nov 12, 2008 at 11:07 UTC | |
|
Re: deleting characters from a string but the characters are in a variable
by GrandFather (Saint) on Nov 12, 2008 at 11:07 UTC | |
|
Re: deleting characters from a string but the characters are in a variable
by Anonymous Monk on Nov 12, 2008 at 10:59 UTC | |
|
Re: deleting characters from a string but the characters are in a variable
by ww (Archbishop) on Nov 12, 2008 at 12:19 UTC | |
by Anonymous Monk on Nov 12, 2008 at 13:38 UTC |