Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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

In reply to Re^3: Reading a hash structure stored in a file by haukex
in thread Reading a hash structure stored in a file by sam1990

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (2)
As of 2024-04-19 19:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found