There's definitely more than one way to do this, but I thought I'd KISS, and combine the two values into one hash key instead of using two hashes. That also simplifies the display. It looks like this:
#!/usr/bin/perl -w use strict; my ($x, $y); my %hash; my $key; while (<DATA>) { /(\w.*)\ (\w.*)/; $key = int($1) . ' ' . int($2); $hash{$key}++; } foreach my $item (sort( keys(%hash))) { print $item . ': ' . $hash{$item} . "\n"; } __DATA__ 123.7 456.7 564.7 234.9 123.7 456.7 564.7 234.9 654.9 132.7 518.0 025.3
In reply to Re: placing values into bins
by pboin
in thread placing values into bins
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |