Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Changing local variables in subroutine by passing by reference?

by almut (Canon)
on Feb 29, 2008 at 10:23 UTC ( [id://671138]=note: print w/replies, xml ) Need Help??


in reply to Changing local variables in subroutine by passing by reference?

You have a precedence problem in your dereferencing ($$_[2] and @$_[1]), i.e. you need additional braces.  And, as moritz said, you need to dereference in the assignment, too. IOW, this should work:

... print "count is: ${$_[2]} , reference is: $_[2] \n"; print "data is: @{$_[1]} , reference is: $_[1] \n"; ${$_[2]} = 0; @{$_[1]} = (); ...

Replies are listed 'Best First'.
Re^2: Changing local variables in subroutine by passing by reference?
by why_bird (Pilgrim) on Feb 29, 2008 at 10:32 UTC
    That might answer my question before.. I'll read up on operator precedence.. Thanks :)
    -------------------------------------------------------------
    Those are my principles. If you don't like them, I have others.
    -- Groucho Marx
    --------------------------------------------------------------

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2024-04-14 17:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found