my $x; my %y = (); while( $x = getvaluesofx() ) { $y{$x} += 1; }