for ($i=0;$i<=$#id;$i++) {
    $randomtext =~ s/$name[$i]/$name[$i] $id[$i]/g
}

Putting the word-break identifiers around your search text will prevent "J Smithers" from getting replaced when the $i for "J Smith" comes around.

    $randomtext =~ s/\b$name[$i]\b/$name[$i] $id[$i]/g

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to