in reply to Learning Perl, Hashes Help

Tip #1 from the Basic debugging checklist... warnings

use warnings; my %myhash = (); my @data = (); chomp(@data = <DATA>); foreach (@data) { $myhash{$_}++; } foreach $k (sort {$a <=> $b} keys %myhash) { print "$k : ". '*' x $myhash{$k} . "\n"; } __DATA__ 1 2 3 3 2 2 1 2

Replies are listed 'Best First'.
Re^2: Learning Perl, Hashes Help
by learningmanylang (Initiate) on Apr 29, 2014 at 01:05 UTC

    Awesome, I actually had it like that first, but I had $myhash{$k}++; instead of $myhash{$_}++;
    Perl has been like reading Chinese compared to all of the other wordier languages I'd been working with.