#!/usr/bin/perl use warnings; use strict; my $txt = 'test'; my $foo = 'foo'; $txt =~ s/test/$foobar/; print "$txt\n";