Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^3: Reading a hash structure stored in a file

by haukex (Archbishop)
on Jan 22, 2019 at 14:43 UTC ( [id://1228817]=note: print w/replies, xml ) Need Help??


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

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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2024-04-25 22:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found