in reply to Re: Reading a hash structure stored in a file
in thread Reading a hash structure stored in a file

On top of all of those problems, the string eval will run at runtime, which is far too late for the strict 'vars' check to find out that %hash1 has been declared.
  • Comment on Re^2: Reading a hash structure stored in a file

Replies are listed 'Best First'.
Re^3: Reading a hash structure stored in a file
by haukex (Archbishop) on Jan 22, 2019 at 14:43 UTC
    the string eval will run at runtime, which is far too late for the strict 'vars' check to find out that %hash1 has been declared

    Did you mean "hasn't been declared"? If yes, then note that the strict check still kicks in, although as you said, at runtime. If you meant it as written, then this doesn't make sense to me... use strict 'vars'; has nothing to do with variables being declared twice (that's just a warning, in the shadow category, and it doesn't happen if the variables are in different scopes).

    $ perl -wMstrict -le 'eval "%hash1=(); 1" or warn "<<$@>>"' <<Global symbol "%hash1" requires explicit package name (did you forge +t to declare "my %hash1"?) at (eval 1) line 1. >> at -e line 1. $ perl -wMstrict -le 'my %hash1; my %hash1; print "Foo";' "my" variable %hash1 masks earlier declaration in same scope at -e lin +e 1. Foo $ perl -wMstrict -le 'my %hash1; { my %hash1; } print "Foo";' Foo $ perl -wMstrict -le 'my %hash1; eval "my %hash1;"; print "Foo";' Foo