Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: How to access a variable inside subroutine?

by haukex (Archbishop)
on Sep 05, 2020 at 19:20 UTC ( [id://11121382]=note: print w/replies, xml ) Need Help??


in reply to How to access a variable inside subroutine?

jeffenstein has said why it doesn't work, I'm wondering what you're trying to achieve? Depending on that, there are several possible solutions, one would be to have the subroutine return the value of $add so you can access it outside the subroutine. Another, though less common in Perl, would be to have the subroutine modify its arguments. And although I hesitate to mention it, you could also use a global variable.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-04-26 07:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found