in reply to Having to specify $_
sub collect (&@) { collect( $_[0]->() || return @_[1 .. $#_] ) } my @results = collect { $sth->fetchrow_hashref };
:^)
Of course, what you really want to do is use one of the fetchall methods - if your result matrices are typically large, the function call overhead for repeated fetchrows is significant.
Update: I can't believe noone called me on my massive stupidity. Anyway, this one will actually work. (Ampersand call form is intended.)
sub collect (&) { ($_[0]->() || return), &collect; } my @results = collect { $sth->fetchrow_hashref };
Makeshifts last the longest.
|
---|
In Section
Seekers of Perl Wisdom