in reply to How to find SELECT tag in HTML and print its values?

Some code would be nice, other then that look at CGI, LWP, WWW::Mechanize, and Ovid's Cgi course.

"Cogito cogito ergo cogito sum - I think that I think, therefore I think that I am." Ambrose Bierce

  • Comment on Re: How to find SELECT tag in HTML and print its values?

Replies are listed 'Best First'.
Re: Re: How to find SELECT tag in HTML and print its values?
by parikhs (Initiate) on Mar 24, 2004 at 17:08 UTC
    $file_name="index.htm"; open FILE, "$file_name" or die "can't read file: $!"; $char = getc FILE; while($char=<MYFILE>) { $pattern1="select class=form"; if(/$pattern1/i)#search for the string { $pattern2="option"; if(/$pattern2/i)#search for the options { $pattern3="value"; if(/$pattern3/i)#search if the options has value associa +ted with it { print $pattern4="/select"; open (MYFILE, ">save.txt") or die "no such file"; ............. .......... }//end first if statement }//end second if statement }//end while

    edit (broquaint): added <code> tags

      You've really got a lot of nonsense in your code. The getc, for example -- what's that about?

      It looks like you're expecting to find everything on the same line (select class, option, and value). If so, you might as well construct one pattern to extract what you want, rather than doing the nested ifs.

      For real HTML, using the modules that are designed to parse real HTML is the only sensible choice. If this is a learning exercise, you need to get a really clear idea of what you want your program to do, step-by-step, and then review your code to ensure that it is actually doing that.


      The PerlMonk tr/// Advocate
      Why do you read a single character from 'index.htm', which you then discard? Where's MYFILE coming from? Why are you opening the same handle you read from in your condition for writing in the body of the while?

      Abigail

      I know Perl

      You might want to brush up on the basics.