my %escape = map { ( chr($_) => eval '"\\'.chr($_).'"'||undef ) } 0 .. 127; sub interpolate { my ($s) = @_; $s =~ s/\\c(.)/chr(ord(lc($1))-ord('`'))/ge; $s =~ s/\\x([a-fA-F0-9]{2})/chr(hex($1))/ge; $s =~ s/\\0([0-9]{1,3})/chr(oct($1))/ge; $s =~ s/\\0/\0/g; $s =~ s/\\(.)/$escape{$1}/gs; return $s; }