Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re^3: Way to do a "scalar ref"?

by moritz (Cardinal)
on Sep 26, 2011 at 09:02 UTC ( #927826=note: print w/replies, xml ) Need Help??

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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://927826]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2018-01-21 17:03 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (228 votes). Check out past polls.