Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
      You're declaring your variables with my, so as soon as you leave the eval block they go out of scope.

Good thought... taking the "my" out now gives the following spew:

$ perl loadData.pl Name "main::fum" used only once: possible typo at loadData.pl line 16. Name "main::fo" used only once: possible typo at loadData.pl line 16. Name "main::fi" used only once: possible typo at loadData.pl line 16. Name "main::fee" used only once: possible typo at loadData.pl line 16. Variable "$fee" is not imported at (eval 1) line 1, <DAT> line 1. Global symbol "$fee" requires explicit package name at (eval 1) line 1 +, <DAT> line 1. Variable "$fi" is not imported at (eval 2) line 1, <DAT> line 2. Global symbol "$fi" requires explicit package name at (eval 2) line 1, + <DAT> line 2. Variable "$fo" is not imported at (eval 3) line 1, <DAT> line 3. Global symbol "$fo" requires explicit package name at (eval 3) line 1, + <DAT> line 3. Variable "@fum" is not imported at (eval 4) line 1, <DAT> line 4. Global symbol "@fum" requires explicit package name at (eval 4) line 1 +, <DAT> line 4. $VAR1 = undef; $VAR2 = undef; $VAR3 = undef;
Following that thought one step further, let's declare them as "our." Run the code and we still see spew, but not as severe:
$ perl loadData.pl Name "main::fum" used only once: possible typo at loadData.pl line 16. Name "main::fo" used only once: possible typo at loadData.pl line 16. Name "main::fi" used only once: possible typo at loadData.pl line 16. Name "main::fee" used only once: possible typo at loadData.pl line 16. $VAR1 = 'FEE'; $VAR2 = 'FI'; $VAR3 = 'FO'; $VAR4 = 'fee'; $VAR5 = 'fi'; $VAR6 = 'fo'; $VAR7 = 'fum';

I guess in the end that means that you have to pre-declare the variables before reading in the "configuration file" and getting the values defined. Not pretty... but it works. I like the way I normally do it better. Which is to sey I either create a module and export my values or I use something like XML::Simple to do the dirty work.


In reply to Re^2: eval not behaving like I expected... why? by blue_cowdawg
in thread eval not behaving like I expected... why? by blue_cowdawg

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 drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2024-04-23 12:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found