#!/usr/bin/env perl use strict; use warnings; my @array=(); $array[0][0] = "ape"; $array[0][1] = "bear"; $array[0][2] = "cat"; $array[1][0] = "dog"; $array[1][1] = "emu"; $array[1][2] = "fox"; $array[2][0] = "goat"; $array[2][1] = "horse"; $array[2][2] = "ibex"; for (qw{goat gout dog goatee ape}, "goat's milk") { my $found = search_col(\@array, 0, $_); print "'$_' ", (defined $found ? "found on row $found" : 'not found' ), "\n"; } sub search_col { my ($array, $col, $search) = @_; my $result; for my $row (0 .. $#$array) { next unless $array->[$row][$col] eq $search; $result = $row; last; } return $result; } #### 'goat' found on row 2 'gout' not found 'dog' found on row 1 'goatee' not found 'ape' found on row 0 'goat's milk' not found