#!/usr/bin/perl use strict; use warnings; my $infile = shift or die "Usage: $0 raw_input_file_name\n"; my $file_size = -s $infile; open( my $fh, $infile ) or die "$infile: $!\n"; read( $fh, my $buf, $file_size ); my @ints=unpack("s*", $buf); print scalar @ints, " short-int elements read\n"; print " ... which seems right\n" if ( @ints == $file_size/2 ); my %h; $h{$ints[$_]}++ for (0..$#ints); print "distinct int values found in $infile:\n"; print " $_ occurs $h{$_} times\n" for (keys %h);