in reply to Re^5: Too much SQL not enough perl
in thread Too much SQL not enough perl
No, that’s not it. I admit I don’t (yet?) understand why that happens exactly, but what happens is that the last causes grep to return the entire list. Observe:
my @candidates = qw( z y a b c a d a e a f ); foreach my $question ( 'a', 'd', 'm' ) { my @x = do { {; grep { $_ eq $question ? last : 0 } @candidates } +}; print "$question: @x\n"; } __END__ a: z y a b c a d a e a f d: z y a b c a d a e a f m:
Update:
<tye> grep works by moving things around on the stack and then reseting the count. you leave early, you get what's on the stack with the original count
Makeshifts last the longest.
|
|---|