Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: read a few lines, put them into named variables

by robsv (Curate)
on Feb 22, 2001 at 01:43 UTC ( #60045=note: print w/ replies, xml ) Need Help??


in reply to read a few lines, put them into named variables

merlyn,
This is very cool! I did run into one small quirk in the key/value pair example - it doesn't stop (I think because the last drops out of the for, not the loop block). I got it to work as:

LOOP: { defined($_ = <STDIN>) or last LOOP for my($key,$value); chomp($key,$value); $hash{$key} = $value; redo; }
I guess the chomp really isn't necessary, but I wanted to ditch the newlines. Thanks!

- robsv


Comment on Re: read a few lines, put them into named variables
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2015-07-04 00:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (57 votes), past polls