in reply to replacing strings using reg exp

There are a couple of errors in your code:

  1. if($thing2 =~ /\s*<$thing\s*>/)

    For your examples this line equates to

    if( 'abcd<Utly>' =~ /\s*<Ut\s*>/)

    There is no way that \s* will ever match 'ly'.

  2. $thing2 =~ s/$thing/$thing/;

    Even if the match was made, this line is saying: Look in 'abcd<Utly>' for 'Ut' and if you find it replace 'Ut' with 'Ut', which probably isn't what you want:)

If your arrays are of any size, your nested loops comparing every element of one array with every element of the second is going to take a quite a long while to run...if they're small then that probably doesn't matter, but you could make the process more efficient by using a hash, but it's probably better to get this one working before you move on.


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
Hooray!