Skip to content

Instantly share code, notes, and snippets.

@wchristian
Created January 26, 2011 10:06
Show Gist options
  • Save wchristian/796502 to your computer and use it in GitHub Desktop.
Save wchristian/796502 to your computer and use it in GitHub Desktop.
my @dest_airports = split ',', $hotel->{airports};
my $counter = 0;
for my $airport ( @filtered_dest_airports ) {
if ( !$has_flights_cache{$airport} ) {
$counter++;
next;
}
# ...
# code here
# ...
}
print "filtered out $counter airports without flights";
###### versus: #####
my @dest_airports = split ',', $hotel->{airports};
my @filtered_dest_airports = grep $has_flights_cache{$_}, @dest_airports;
print "filtered out ".( @dest_airports - @filtered_dest_airports )." airports without flights";
for my $airport ( @filtered_dest_airports ) {
# ...
# code here
# ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment