Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: Parsing multiple rows of text and converting to columns

by hdb (Monsignor)
on Jun 25, 2013 at 06:23 UTC ( #1040541=note: print w/replies, xml ) Need Help??

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

If you set $/="" then the <FILE> construct will read in paragraphs, ie blocks of lines separated by empty lines.

Within these paragraphs, you can extract your data with a regular expression. For example, /Findings\|(\d+)\|(.*)>\n(.*)/ would extract the record number, the item description and the value as $1, $2 and $3. You could store them in a hash like this $hash{$1}{$2} = $3 for further processing, sorting and printing.

Replies are listed 'Best First'.
Re^2: Parsing multiple rows of text and converting to columns
by gingeremmie (Initiate) on Jun 25, 2013 at 09:47 UTC
    Thank you everybody, much appreciated, I will go and do some experimenting with the ideas you have given me
    Not sure why I was told to post my code in code tags because I didn't post any code? My code is non existent at the moment hehe! I just posted the raw data I was trying to extract. Should that have been in code tags? I wouldn't have thought so but I'm new to this, so would be grateful if someone could let me know.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2018-02-22 13:15 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (293 votes). Check out past polls.