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

Re: dynamic scalar names?

by dga (Hermit)
on Aug 01, 2003 at 21:41 UTC ( [id://280163]=note: print w/replies, xml ) Need Help??


in reply to dynamic scalar names?

I would suggest a hash.

my %file_stuff; while(<DATA>) { chop; my($k, $v)=split('='); $file_stuff{$k}=$v; } #later want to know what data was set to print "data was ", $file_stuff{data}, "\n"; __DATA__ data=test other=sample

This keeps the names and keeps them tidy and doesn't pollute your name space. As an added advantage you can look through the keys to see what was defined.

my @defined_stuff=keys %file_stuff;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (7)
As of 2024-04-23 12:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found