Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Combining multiple lines based on the given condition

by Eily (Hermit)
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
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 making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2014-08-30 16:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (293 votes), past polls