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

Re: amalgamate similar lines

by Perl Mouse (Chaplain)
on Jan 09, 2006 at 13:39 UTC ( [id://521912]=note: print w/replies, xml ) Need Help??


in reply to amalgamate similar lines

Untested:
my %info; while (<>) { my ($key, $value) = /([^|]*\|[^|]*)\|(.*)/; push @{$info{$key}}, $value; } while (my ($key, $value) = each %info) { local $" = ","; print "$key|@$value\n"; } __END__
Perl --((8:>*

Replies are listed 'Best First'.
Re^2: amalgamate similar lines
by ysth (Canon) on Jan 09, 2006 at 13:57 UTC
      Yes - I don't think the OP stated any requirements about the order. A required ordering is easily added without changing the gist of the solution.

      And I'm not going to speculate what the OP wants or not.

      Perl --((8:>*

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (3)
As of 2024-03-29 04:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found