Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Combining multiple lines based on the given condition

by Eily (Curate)
on Oct 18, 2013 at 19:20 UTC ( #1058806=note: print w/ replies, xml ) Need Help??


in reply to Combining multiple lines based on the given condition

The first 13 lines of Text::CSV already show you how to do half the work (there is one extra line though). Except instead of pushing into an array, you have to push the row inside a hash of arrays with the first column has the key.

push @{ $yourHash{shift @$row} }, @$row # shift returns the first element of an array and deletes it from it

If you don't know how to uses hashes and hashes of arrays, read perldsc

Edit: ahem ... square brackets for a hash ... this wouldn't have worked well.


Comment on Re: Combining multiple lines based on the given condition
Download Code
Replies are listed 'Best First'.
Re^2: Combining multiple lines based on the given condition
by anony (Initiate) on Oct 18, 2013 at 19:42 UTC
    Could you please help me bit more. Because I'm new to perl. Thanks.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (8)
As of 2015-07-30 03:35 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 (269 votes), past polls