$file_name="index.htm"; open FILE, "$file_name" or die "can't read file: $!"; $char = getc FILE; while($char=) { $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 associated with it { print $pattern4="/select"; open (MYFILE, ">save.txt") or die "no such file"; ............. .......... }//end first if statement }//end second if statement }//end while