Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: amalgamate similar lines

by Perl Mouse (Chaplain)
on Jan 09, 2006 at 13:39 UTC ( #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
Node Status?
node history
Node Type: note [id://521912]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2020-10-20 09:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (209 votes). Check out past polls.

    Notices?