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