# Where's "use strict", "use warnings"? # Where's your error checking for open? if (open(MYFILE,"htmlfile.txt")) { $line = ; # Don't think this regex is going to do what you want. Should probably focus on this first and see if @array contains what you expect. We might be able to suggest a better regex if we actually saw teh real data. @array = ($line =~ m/<.^>*>/g); print"ARRAY iS @array\n"; for ($i=0;$i<@array;$i++){ print "The Element $i is $array$i\n"; } for ($j=0; $j<@array; $j++){ for ($k=$j+1; $k<@array; $k++){ # What's this you're tryign to do here? if ($array$j eq $array$k){ # Another hrm... print " substring($array$j,$array$k)\n"; } } } }