in reply to i dont like the way my code looks but work

The contents of your two loops don't look very similar at all, so I don't think you can unify them easily.

But this:

for (keys %total) { push @matches, $_ if $_ eq "$item"; }
looks like it could be simplified to:
push @matches, $item if exists $total{$item};

Replies are listed 'Best First'.
Re^2: i dont like the way my code looks but work
by alexm (Chaplain) on Jan 27, 2008 at 20:21 UTC
      hey thank you for the good pointer to that website.. I really like Mark Dominus's articles...
      the fact that I understood where he was going w/ below code got me really happy... After about close to year of struggle w/ perl(and still struggling mightly w/ it), I feel I have some understanding in some area~<very very limited>
      thanks again!
      for my $k (keys %hash) { if ($k eq "name") { $hash{$k}++; } }