I am using DBI
selectall_array
to fetch all the data out of mysql. My query returns 1 columns for every row. But the selectall_array
function returns an array of array ref for each row as listed below
$VAR1 = [
'1.ptmp'
];
$VAR2 = [
'e1.ptmp'
];
$VAR3 = [
's2.ptmp'
];
$VAR4 = [
'sw1.ptmp'
];
$VAR5 = [
'w1.ptmp'
];
What I would like is a way to extract all the domains into a single array (no refs) or is there a DBI function which returns a full array of data without any references? I dont want to loop through all data or do fetchrow_array
in a while loop. Looking for a single statement to do it all if possible?
Please see my code below:
my @mysqldata = $dbh->selectall_array('SELECT `domain` FROM dfs WHERE `id` IN ('.join(',',('?')x(scalar(@params))).')', {}, @params);
my @minus = array_minus( @all, @mysqldata );
You can dereference the arrayrefs into one big array in one line like this:
The
map
block applies@$_
to each row returned byselectall_array
, which dereferences the arrayref.