in reply to List columns for a MySQL table

# loop through ref and extract only the column name my @cols; foreach my $i (0..$#{$ref}) { push(@cols, $ref->[$i]->[3]); }

Any time you're taking an array, and creating another array based on values from it, you should think about using map, rather than an initialize & push in a foreach loop:

my @cols = map { $_->[3] } @$ref;