@kyanny's blog

My thoughts, my life. Views/opinions are my own.

no strict 'refs';

no strict 'refs';
my $foo = 100;
our $bar = 200;
my $ref = \$foo;
warn $$ref; # => 100
$ref = 'foo';
warn $$ref; # => Warning: something's wrong
$ref = 'bar';
warn $$ref; # => 200

my で宣言した変数は no strict 'refs'; のもとで $$ref を $foo として扱いたい場合に、うまく参照できない。 our で宣言しているとできる。スコープが関係しているんだと思う、けどそれ以上はよくわからない。