Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: Way to do a "scalar ref"?

by doug (Pilgrim)
on Sep 26, 2011 at 17:14 UTC ( #927905=note: print w/ replies, xml ) Need Help??

in reply to Way to do a "scalar ref"?

You can explicitly pass a reference if you like, or you can use the dark voodoo of prototypes. You could define

sub test(\$) { my ($scalar_ref) = @_; $$scalar_ref =~ tr/a-m/N-Z/; substr($$scalar_ref, 0, 0) = "prepended sumthin'"; }

and it should do what you want. Just make calls like


until your heart is content. You just have to make sure that test(\$) is seen before making the call. And be careful what you pass as an argument to test() because prototypes can work differently than you think they should.

Comment on Re: Way to do a "scalar ref"?
Select or Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://927905]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2015-11-29 15:05 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (751 votes), past polls