Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: What is it I don't understand about perl scoping?

by YuckFoo (Abbot)
on Jul 09, 2009 at 18:18 UTC ( #778647=note: print w/ replies, xml ) Need Help??


in reply to What is it I don't understand about perl scoping?

While I appreciate you may be just using this code to understand how scoping works, the advice I think you really need is quit having these thoughts and expectations, resist. These variables should be passed to the function. Stop running with scissors!

#!/usr/local/bin/perl use strict; my $foo = 1; my $fum = 1; print STDERR "variables are now: $foo $fum\n"; foo($foo, $fum); my $foo = 2; $fum = 2; print STDERR "variables are now: $foo $fum\n"; sub foo { my $foo = shift; my $fum = shift; print STDERR "variables are now: $foo $fum\n"; }


Comment on Re: What is it I don't understand about perl scoping?
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2014-12-19 03:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (70 votes), past polls