Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: eval not behaving like I expected... why?

by blue_cowdawg (Monsignor)
on Mar 13, 2006 at 21:27 UTC ( [id://536390]=note: print w/replies, xml ) Need Help??


in reply to Re: eval not behaving like I expected... why?
in thread eval not behaving like I expected... why?

      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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://536390]
help
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: (5)
As of 2024-04-19 10:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found