@listA = ('This=That', 'Some=Song'); @listB = ('Other=That', 'Corny=Song'); #### $text =~ s/.+?=/$new_text=/; #### foreach (@listA, @listB) { # or just one of the two, whatever # set $new_text to whatever you want s/.+?=/$new_text=/; } #### s/.+?(?==)/$new_text/;