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