#!/usr/bin/perl # chist.perl -- print histogram of byte values # (useful for seeing if text contains invisible characters) while (<>) { @chars = split //; for $c ( split // ) { $chist[ord($c)]++; } } for ( $i=0; $i<256; $i++ ) { printf("%d\tx%0.2x\n", $chist[$i], $i) if ( $chist[$i] ); } # there are ways to reduce that to a fairly short one-liner, # but you may want to add options...