while ($line = <>) { for ( split //, $line ) { $symbol{ $_ }++; $total++; } }