Last active
March 25, 2019 01:34
-
-
Save worthmine/59a00d63c94d0f61e4358a8bc1fccb2a to your computer and use it in GitHub Desktop.
the strange declaration with our, my and local is here.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use feature qw(say); | |
use strict; | |
use warnings; | |
package Some; | |
our $n = 100; | |
sub say_n { | |
say $Some::n; | |
} | |
say_n(); | |
{ | |
for ( local $n = 0; $n < 10; $n++ ) { | |
say_n(); | |
} | |
#0 | |
#1 | |
#2 | |
#3 | |
#4 | |
#5 | |
#6 | |
#7 | |
#8 | |
#9 | |
say '---'; | |
for ( my $n = 0; $n < 10; $n++ ) { | |
say_n(); | |
} | |
#10 | |
#10 | |
#10 | |
#10 | |
#10 | |
#10 | |
#10 | |
#10 | |
#10 | |
#10 | |
say '---'; | |
say_n(); | |
} | |
say_n(); | |
#100 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment