#!/usr/bin/perl -w use strict; my %hash; # don't want these keys in the subroutine $hash{'ytd'} = 1.5; $hash{'mtd'} = 2.0; $hash{'wtd'} = 2.5; # store what I don't want here my @do_not_want = qw{ ytd mtd wtd }; # want these keys and any others in subroutine $hash{'Jumbo_Tron'} = "United Center"; $hash{'Meat_Pie'} = "Gross"; $hash{'Word'} = "Association"; # my try, grepping each item in @do_not_want into a larger grep foreach my $anything_but ( grep { grep { }, @do_not_want }, keys %hash ) { # print every key except for "ytd", "mtd", and "wtd" print $anything_but . "\n"; }