Skip to content

Instantly share code, notes, and snippets.

@worthmine
Last active March 25, 2019 01:34
Show Gist options
  • Save worthmine/59a00d63c94d0f61e4358a8bc1fccb2a to your computer and use it in GitHub Desktop.
Save worthmine/59a00d63c94d0f61e4358a8bc1fccb2a to your computer and use it in GitHub Desktop.
the strange declaration with our, my and local is here.
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