in reply to Re: extract string between 2 elements
in thread extract string between 2 elements

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 ?
  • Comment on Re^2: extract string between 2 elements

Replies are listed 'Best First'.
Re^3: extract string between 2 elements
by wind (Priest) on Feb 17, 2011 at 23:28 UTC
    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"; } } } }