Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

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

by youlose (Scribe)
on Jul 09, 2009 at 12:05 UTC ( [id://778551]=note: print w/replies, xml ) Need Help??


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

use strict;

my $foo = 1;
my $fum = 1;

print STDERR "variables are now: $foo $fum\n";

{
    my $foo = 2;
    $fum = 2;
    &foo();
    print STDERR "variables are now: $foo $fum\n";

}

sub foo {
    print STDERR "variables are now: $foo $fum\n";

}



Resulting:
variables are now: 1 1
variables are now: 1 2
variables are now: 2 2
as you wanted
  • Comment on Re: What is it I don't understand about perl scoping?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (1)
As of 2024-04-25 00:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found