Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Parsing multiple rows of text and converting to columns

by Laurent_R (Parson)
on Jun 24, 2013 at 17:57 UTC ( #1040472=note: print w/ replies, xml ) Need Help??


in reply to Parsing multiple rows of text and converting to columns

You could use a regex to fetch the last part of the line and read immediately the next line. Something like this:

my %vals; while (my $line = <$IN>) { if ($line =~ />/) { my $element = $1 if $line =~ /\|([^|]+)>\s*$/; $line = <$IN>; chomp $line; $vals{$element}=$line; } }

Then you only need to print the hash.


Comment on Re: Parsing multiple rows of text and converting to columns
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2014-09-20 20:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (163 votes), past polls