in reply to replacing strings using reg exp
Ugh. You can use @1 and @2 if you are masochistic, but please don't make us read code like that. It's hideous.
That said, I think you are trying to do this:
Notice that there is no reason for a separate if statement. The substitution only takes place if it can.my @abbrs = qw( Ut ); my @strings = qw( abcd<Utly> ); for $abbr ( @abbrs ) { for $str ( @strings ) { $str =~ s/<$abbr(.*)>/<$abbr>/; } }
-sauoq "My two cents aren't worth a dime.";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: replacing strings using reg exp
by etcshadow (Priest) on Oct 17, 2003 at 03:35 UTC | |
by sauoq (Abbot) on Oct 17, 2003 at 05:47 UTC |