tangent has asked for the wisdom of the Perl Monks concerning the following question:
From perldoc:use strict; use warnings; my %hash = (abc=>1,def=>1); my @array = qw/abc def ghi/; my @ary1 = grep{ ! $hash{$_} } @array; # OK my @ary2 = grep( ! $hash{$_}, @array); # OK my @ary3 = grep{ not $hash{$_} } @array; # OK my @ary4 = grep( not $hash{$_}, @array); # NOT OK Errors from fourth statement: Useless use of hash element in void context Not enough arguments for grep near "@array)"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Logical Not and arguments to grep
by chromatic (Archbishop) on Apr 01, 2012 at 20:40 UTC | |
by tangent (Parson) on Apr 01, 2012 at 20:50 UTC | |
by chromatic (Archbishop) on Apr 01, 2012 at 21:19 UTC | |
by Marshall (Canon) on Apr 02, 2012 at 01:02 UTC | |
|
Re: Logical Not and arguments to grep
by ikegami (Patriarch) on Apr 02, 2012 at 19:27 UTC | |
|
Re: Logical Not and arguments to grep ( not( $hash{$_} ) )
by Anonymous Monk on Jun 05, 2013 at 08:10 UTC |