Is there any way to force grep to evaluate these in a scalar context in order to return a "true" or "false" in this case?
Yes, evaluate grep in scalar context. It's that easy!
my $found_any = grep { ... } @whatever;
Boolean context is also a scalar context.
| [reply] [d/l] |
use List::MoreUtils qw(any);
my $found_any = any { ... } @whatever;
or:
use List::Util qw(first);
my $found_any = defined first { ... } @whatever;
...though, in practice, it is unlikely to matter, performance-wise,
unless @whatever is huge.
As an aside, note that both any and first are built in to Perl 6.
| [reply] [d/l] [select] |
Is there any way to force grep to evaluate these in a scalar context in order to return a "true" or "false" in this case?
Something like:
my @date = grep ...
if (@date) { ... }
| [reply] [d/l] |
I just changed the until loop to a while loop and now it's working as expected
Sorry for wasting your time...I was not thinking clearly
while (my @date = grep /$new_ex_date/,@{$countries{$cntry_of_issue}})
{
$new_date=get_next_bus_day($new_date);
}
| [reply] [d/l] |