Skip to content

Instantly share code, notes, and snippets.

@deepakg
Created August 4, 2014 18:45
Show Gist options
  • Save deepakg/c047865c94d9c1438f5f to your computer and use it in GitHub Desktop.
Save deepakg/c047865c94d9c1438f5f to your computer and use it in GitHub Desktop.
use warnings;
use strict;
use Data::Dumper;
use 5.10.1;
my @x = qw(mary had a little lamb);
my @y = qw(nothing common with the girl above);
my @z = qw(claire had a silent white lamb that will not bleat);
my %first;
@first{@x} = (1) x scalar @x;
my @matches = @first{@y};
print Dumper(\@matches);
say scalar(grep { defined $_ } @matches);
@matches = @first{@z};
print Dumper(\@matches);
say scalar(grep { defined $_ } @matches);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment