#!/usr/bin/perl use strict; use diagnostics; use warnings; my $string = 'Hello sailor'; my $regex = 'Hello (.*)'; my $substitution = 'Goodbye \\1'; $string =~ s/$regex/$substitution/; print "string is now $string \n"; # I wanted: string is now Goodbye sailor # I got: string is now Goodbye \1