Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2018-06-17 22:45 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (107 votes). Check out past polls.