Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Parsing multiple rows of text and converting to columns

by Laurent_R (Prior)
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 exploiting the Monastery: (8)
As of 2015-07-03 21:42 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 (56 votes), past polls