Skip to content

Instantly share code, notes, and snippets.

@andrewsolomon
Created May 21, 2017 20:51
Show Gist options
  • Save andrewsolomon/b6b4a0e0f7919e0d7a148764deed3ff3 to your computer and use it in GitHub Desktop.
Save andrewsolomon/b6b4a0e0f7919e0d7a148764deed3ff3 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dump 'pp';
use feature 'say';
sub search_firstname {
my ($match, $rah_phonebook) = @_;
my @matches = grep { $_->{firstname} eq $match } @$rah_phonebook;
return \@matches;
}
my $rah_results = search_firstname ($ARGV[0] || '', [
{ firstname => 'Bill', surname => 'Smith', phone => 123123213 },
{ firstname => 'Anne', surname => 'Taylor', phone => 123123213 },
{ firstname => 'Bill', surname => 'Sinclair', phone => 9999 }
]);
say pp($rah_results);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment