in reply to Re^2: Way to do a "scalar ref"?
in thread Way to do a "scalar ref"?

FWIW @_ and thus $_[0] are already aliases to the variable used in the call, so if you do something like
sub f { $_[0] =~ s/a/b/g } my $text = 'foo bar' f $text

No copying happens.

If you want explicit references, do it like this:

sub f { my $ref = shift; $$ref =~ s/a/b/g } my $text = 'foo bar' f \$text
m working on a wiki (which can have VERY large articles in). The site also gets a lot of traffic (several million hits a month), so I need to make this code as optimized as possible.

Then be sure to read perlperf, and cache wherever possible. If you cache the rendered version of very large articles, the number of renderings becomes proportional to the number of writes, which is usually much lower than the number or reads.