Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Parsing multiple rows of text and converting to columns

by Laurent_R (Monsignor)
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 lurking in the Monastery: (13)
As of 2015-07-31 20:09 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 (281 votes), past polls