my @rv = $dbh -> selectall_arrayref( $commands, undef, ( $query ) ); foreach my $value (@rv) { my @deref = @{ $value }; foreach my $subval (@deref) { foreach my $ssval (@{$subval}) { print "$ssval"; <>; } } }