in reply to extract string between 2 elements

Your problem is probably due to the fact that you are only reading the first line from the file and none of the others.

Replies are listed 'Best First'.
Re^2: extract string between 2 elements
by satishchandra (Initiate) on Feb 17, 2011 at 23:20 UTC
    hey, yes iam reading only one line , i just want to try with one line,as the same logic applies for n lines iam trying to extract a string between two tags ,is my program correct ?
      Nope, doesn't look like it is.
      # Where's "use strict", "use warnings"? # Where's your error checking for open? if (open(MYFILE,"htmlfile.txt")) { $line = <MYFILE>; # Don't think this regex is going to do what you want. Should pro +bably 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 r +eal 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"; } } } }