Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: subroutine syntax

by marius (Hermit)
on Dec 10, 2000 at 13:36 UTC ( #45932=note: print w/ replies, xml ) Need Help??


in reply to subroutine syntax

The thing you are missing is do you really need to use $xyz outside of the scope of the subroutine. I would read up on variable scope in the Llama book and/or the Camel book. Basically, you can substitute the following:

&example(15); sub example { my($xyz) = shift || 0; my($a) = $xyz + 49; print $xyz; print $a }
After doing this, $a and $xyz won't be available to you outside of the subroutine. This is all assuming you're operating under strict. Really, you ought to read the Llama book if nothing else, it's fantastic information and explains a lot of this much more clearly than I can. =]

-marius


Comment on Re: subroutine syntax
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2014-09-20 16:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (160 votes), past polls