in reply to Passing with $_ instead of @_ in anonymous subs
It is OK because:
for (@items) { return 0 unless $self->($_); }
'for' localizes $_ correctly and therefor $_ is what you expect it to be. This is perfectly OK.
How about this btw.:
--sub filter (&@){ my $sub = shift; for(@_){ return unless $sub->() } 1 } print +( filter {/foo/} qw/foobar foobar bazfoo/ ) ? 'y' : 'n' , "\n";
|
|---|