my $data = {}; my $SQL = "SELECT * FROM my_table ORDER BY order"; my $sth = $dbh->prepare( $SQL ); $sth->execute() or die DBI->errstr; my %row; $sth->bind_columns( \( @row{ @{ $sth->{ NAME_uc } } } )); $i = 1; while ( $sth->fetch() ){ push @names, $row{ 'NAME' }; delete $row{ 'NAME' }; #this line causes problem at 'bind_columns' down there $data->{"data_$i"} = { %row }; $i++; } $sth->finish(); my $second_data = {}; $SQL2 = "SELECT * FROM my_second_table ORDER BY order"; my $sth2 = $dbh->prepare( $SQL2 ); $sth2->execute(); my %row2 = (); $sth2->bind_columns( \( @row2 { @{ $sth2->{ NAME_lc } } } )); # Error due to delete $row{ 'NAME' }; at top $i=1; while ( $sth2->fetch() ){ $second_data->{"data_$i"} = { %row2 }; $i++; } $sth2->finish(); #### "Can't use an undefined value as an ARRAY reference at /myprogram.pl line 23." #### $sth2->bind_columns( \( @row2 { @{ $sth2->{ NAME_lc } } } )); #### while ( $sth->fetch() ){ %record=%row; push @names, $record{ 'NAME' }; delete $record{ 'NAME' }; $data->{"data_$i"} = { %record }; $i++; } #### while ( $sth->fetch() ){ %record=(%row); push @names, $record{ 'NAME' }; delete $record{ 'NAME' }; $data->{"data_$i"} = \%record; $i++; }