in reply to Regex or Index
On the the third hand, if you were using a DBI function that returns one row per iteration, you could split the set within the fetch loop, like this:@A_K = grep /^[A-K]/, @query_results; @L_Z = grep /^[L-Z]/, @query_results;
my @A_K; my @L_Z; my $aref = \@A_K; while ( my $row = $dbh->fetchrow_arrayref ) { $aref = \@L_Z if ( $$row[$last_name_col] =~ /^L/ ); push @$aref, [ @$row ]; }
update: Note that the latter
both methods
assume that you're still using the "ORDER BY" clause in
your SQL; in the former, the sequence is preserved in both
subsets; in the latter, once you hit a name that starts with "L", you
switch to the second array for collecting all remaining
rows.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regex or Index
by Abigail-II (Bishop) on Nov 21, 2002 at 10:03 UTC |