Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Parsing multiple rows of text and converting to columns

by Laurent_R (Canon)
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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1040472]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2017-12-16 09:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (449 votes). Check out past polls.

    Notices?