Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: hash name as a variable?

by Roger (Parson)
on Sep 15, 2004 at 15:22 UTC ( [id://391210]=note: print w/replies, xml ) Need Help??


in reply to hash name as a variable?

Your regex test
$DB_name =~ /[ISWLIVE ISWTEST ISWTEACH]/

should really be
$DB_name =~ /(ISWLIVE|ISWTEST|ISWTEACH)/

And then later...
each %$DB_name
I would create a reference to hash with:
$HREF = eval "\\\%$DB_name"; ... if ($HREF->{key} ...)

Replies are listed 'Best First'.
Re^2: hash name as a variable?
by samtregar (Abbot) on Sep 15, 2004 at 20:54 UTC
       $HREF = eval "\\\%$DB_name";

    Ouch. Please don't do that! And if you do, please check $@ afterwards since eval will trap fatal errors silently.

    -sam

      Thanks - I think you just helped me solve a different problem.
      Checking $@ showed where my script was bombing.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2024-04-26 02:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found