in reply to how to count the no of repeats in a string
#!/usr/bin/env perl use warnings; use strict; use Data::Dumper; my $string = '1,3,5,7,9,1,3,4,5,6,2,1,5,6,7,9'; my @numbers = sort split /,/, $string; my %seen; for (@numbers) { if ($seen{$_}) { $seen{$_} += 1; } else { $seen{$_} = 1; } } print "@numbers\n"; print Dumper(\%seen);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: how to count the no of repeats in a string
by ikegami (Patriarch) on Nov 13, 2007 at 19:31 UTC |