Subject: | Another example to bind columns |
The H.Merijn Brand example to [binds columns](https://metacpan.org/pod/DBI#bind_columns) to the values inside a hash is useful:
$sth->bind_columns( \( @row{ @{$sth->{NAME_lc} } } ))
but has a weakness: If data already fetched call to ->bind_columns will flush current values.
If you want to bind_columns after you have fetched you can use:
use feature 'refaliasing';
no warnings "experimental::refaliasing";
while( my $row = $sth->fetchrow_arrayref ) {
\(@$data{ $sth->{NAME_lc}->@* }) = \(@$row);
}
For older perls:
use Data::Alias;
alias @$data{ $sth->{NAME_lc}->@* } = @$row;
This is useful in situations when you have many left joins, but wanna to join your %$data hash to only subset of fetched values.