in reply to Adding the duplicate data using arrays
how do i compare the array data?...Using a hash you don't have to compare data because all you need is just a hash key to hold all the data that belong to that type of fruit... Consider
use strict; use warnings; use Data::Dumper; my %hash; while(<DATA>){ my ($key, $number)=split; $hash{$key} +=$number; } print Dumper (\%hash); __DATA__ apples 10 oranges 3 apples 3 oranges 7
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
| A reply falls below the community's threshold of quality. You may see it by logging in. |