in reply to Re^2: help with 2D arrays with perl requested
in thread help with 2D arrays with perl requested
#!/usr/bin/perl -w use warnings; use strict; my %count; while (<DATA>) { chomp; my ($x,$y) = split /\s/; ($x,$y) = ($y,$x) if ($x gt $y); $count{"$x $y"}++; } foreach (sort keys %count) { print "people with $_: $count{$_}\n"; } __DATA__ cat dog cat fish pig dog horse fish pig fish dog fish fish cat
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: help with 2D arrays with perl requested
by roboticus (Chancellor) on Apr 30, 2006 at 14:17 UTC |