in reply to Searching Line by Line Multiple Times

use strict; my %suits; while (<>) { $suits{$1}++ if /(hearts|clubs|spades|diamonds)/; } print ($_ . "\n") x $suits{$_} for (keys %suits);

All criticism above is extremely useful. I'd also like to add that print stringifies its arguments anyway, so "$suit" is useless; it may also be harmful later in the development cycle.