sub f { my $ref = shift; $$ref =~ s/a/b/g } my $text = 'foo bar' f \$text