in reply to list item comparison
Where's your code that you have tried?
I'll be nice share some code that should get you started. I'll leave it to you to figure out how to bundle it in a subroutine, how to pass data into and out of it, and any other modifications you need to meet your needs.
use strict; use warnings; my (@list) = (1,1,2,3,4,4,4,5,6,7,7,8,9,10); my %check; foreach my $item (@list) { if (exists $check{$item}) {$check{$item}++;} else {$check{$item} = 1;} } foreach my $key (keys %check) { my $count = $check{$key}; if ($count > 1) { print "$key was in the list $count times.\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: list item comparison
by nitin1704 (Sexton) on Jul 13, 2012 at 02:22 UTC | |
by dasgar (Priest) on Jul 13, 2012 at 03:28 UTC | |
by nitin1704 (Sexton) on Jul 13, 2012 at 04:49 UTC | |
by johngg (Canon) on Jul 13, 2012 at 08:52 UTC | |
by nitin1704 (Sexton) on Jul 13, 2012 at 09:16 UTC |