Perl question - looping through an array of hashrefs

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.

just a question why use an array to hold a single level of hashes.

why dont you just use an anon hash?

that way you can go

while ( ($key, $value) = each %hash ) {
print "$key => $value\n";
}

I hear ya. Unfortunately, this is a program that I don't call all the shots on. This is how the boss wants it done (I assume he has other plans in mind for the future with it of which an array of hashrefs is one critical part).

Anyhoo, here's how you do it:

foreach my $r(@LAYOUT) { 
    $sql_file = (keys %$r)[0];  # corrected
    $sql_text = (values %$r)[0]; # corrected
    print $sql_file; 
    print $sql_text; 
}