Created
May 21, 2017 20:51
-
-
Save andrewsolomon/b6b4a0e0f7919e0d7a148764deed3ff3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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