I have an array of hashrefs that look like the following:
my @LAYOUT = (
{SQL_1 => "select count (*) FROM prospect
WHERE PROCESS_DATE = To_date('INSERT_DATE_HERE', 'mm/dd/yyyy')
and tiff_filename is not null
AND (COST_CENTER BETWEEN 6 AND 69)
and media_source = 'DM'
and lead_type = 'Q'
and vendor = 'ABC'"},
{SQL_2 => "select count (*)
from prospect
WHERE PROCESS_DATE = To_date('INSERT_DATE_HERE', 'mm/dd/yyyy')
and tiff_filename is not null
AND (COST_CENTER BETWEEN 6 AND 69)
and media_source = 'TM'
and lead_type = 'L'
and vendor = 'ABC'"},
{SQL_3 => "select count (*)
from prospect
WHERE PROCESS_DATE = To_date('INSERT_DATE_HERE', 'mm/dd/yyyy')
and tiff_filename is not null
AND (COST_CENTER BETWEEN 6 AND 69)
and media_source = 'LQ'
and lead_type = 'R'
and vendor = 'XYZ'"},
and so on...
);
I'm trying to loop through each one and assign scalar variables to the key and the value.
$sql_file should be the sql file name (SQL_1, SQL_2, SQL_3, etc.)
$sql_text should be the sql itself (select count(*)...)
I'm using a foreach loop. I've tried this to assign the scalars, but am not having any luck:
foreach my $r(@LAYOUT) {
$sql_file = (keys%$r)->[1];
$sql_text = (values%$r)->[1];
print $sql_file;
print $sql_text;
}
What am I doing wrong or how can I re-write this to ge the right information?
Thanks.