in reply to My doubts about using fetchall_arrayref

Your post appears to be confusing the concept of rows and columns.

I would recommend adding an additional parameter to _all_data(). The third parameter could be an arrayref. So the function could look like this:

sub _all_data { my $self = shift; my $sql = shift; my $columns = shift; my %column_hash = map { $_, 1 } @$columns; my $sth = $mssql_dbh->prepare($sql); $sth->execute() || die $sth->errstr; # array indices for each returned row my $rs = $sth->fetchall_arrayref( \%column_hash ); return $rs; }
Now you have to pass the function a list of columns you want it to return.

As hdb mentioned, passing {} to fetchall_arrayref will return all columns. With this above version of _all_data, if you do not pass a third parameter, you will essentially be passing {} to fetchall_arrayref and therefore get all columns.