Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Combining multiple lines based on the given condition

by Eily (Deacon)
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 scrutinizing the Monastery: (6)
As of 2014-12-19 06:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (72 votes), past polls