http://qs321.pair.com?node_id=854237

changma_ha has asked for the wisdom of the Perl Monks concerning the following question:

Hi all i am trying to solve a problem for a long time. where i have data table in a text file like

Apple Grape 100 Ginger Fry 200 Apple Grape 80 Ginger Banana 800 Ginger Fry 150 Ginger Banana 45

I want my output to be like this, where the duplicate data values are added

Apple Grape 180 Ginger Fry 350 Ginger Banana 845

I am trying to do it using array of arrays but not able to proceed much.here is my code

#! /usr/bin/perl use strict; use warnings; use Data::Dumper; my @AoA; open (my $fh ,"<","C:/excl7.txt") or die "Can't open the file"; while (<$fh>){ #chomp ($line); push @AoA,[split]; } foreach my $i (@AoA){ #** how do i compare the array data?... if (@{$i print "@$i\n"; } #my @new =shift (@AoA); #print $AoA[1][0]; #print Dumper \@AoA;
Is there other way which will be easier to do? plz help..thaanks in advance <