my $test = "foo bar"; print "Test is now: $test \n"; test(\$test); print "Test is now: $test \n"; sub test { my ( $ref ) = @_; $$ref =~ s/foo/whatever/g; }