programming-examples/perl/Statement/Using foreach loops with hashes.pl

13 lines
255 B
Perl
Raw Normal View History

2019-11-15 12:59:38 +01:00
@opinions = qw( A b c d e f g h jk r e r t r e e e e e ww );
foreach ( @opinions ) {
++$hash{ $_ };
}
print "Word\tFrequency\n";
print "----\t---------\n";
foreach ( sort keys( %hash ) ) {
print "$_\t", "*" x $hash{ $_ }, "\n";
}