Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

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"; }

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (4)
As of 2020-09-25 11:17 GMT
Find Nodes?
    Voting Booth?
    If at first I donít succeed, I Ö

    Results (137 votes). Check out past polls.