$to_replace=qr/^your_regex_here$/; $my_string=~ s/$to_replace/$better_data/;