#!/usr/bin/perl -w use strict; my @array = (); #actually use code that creates 2d array for ( my $i = 0; $i <= $#array; $i++) { for ( my $j = 0; $j <= $#{$array[$i]}; $j++ ) { if ($array[$i][$j] =~ /something/) { # Do something with $array[$i][$j] } } }