in reply to Searching with grep
{ date => '20161010', day => 'Monday' } =~ /^$search$/
which clearly isn't true. Just modify your expression to match the date part of each element:
my $result = ( grep $_->{date} =~ /^$search$/, @$data ) ? 'Found' : 'N +ot Found';
Update: Note that for larger lists, any from List::Util might be faster if you just want to know whether such an element exists. It also specifies the intent more clearly.
use List::Util qw{ any }; my $result = ( any { $_->{date} =~ /^$search$/ } @$data ) ? 'Found' : +'Not Found';
($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Searching with grep
by Anonymous Monk on Mar 23, 2016 at 18:20 UTC | |
|
Re^2: Searching with grep
by Anonymous Monk on Mar 23, 2016 at 18:24 UTC |