http://www.perlmonks.org?node_id=1006112
Sumtingwong has asked for the wisdom of the Perl Monks concerning the following question:

Pretty new here and not much experience...please bear with me. I am parsing an HTML file for a word in a foreign language. If the word is found, it will add it to a file. However, I put an "else" in there and the regex will no longer work in the opening "if" and defaults to the first "print" statement under the "else". When the "else" block is removed, the regex works. Any help would be greatly appreciated!

open (URDUWORDS, "</Users/me/test.txt") || die "Can't open files: $!"; while (<URDUWORDS>) { chomp; my $sw = $_; open (PLATTS, "</Users/me/platts_wkg.html") || die "Can't open files: $!"; while (<PLATTS>) { if (/^.*?<p>.*?( $sw )/) { print "$sw \t $_ \n"; print "Add this definition? "; chomp (my $dec = <STDIN>); if ($dec eq "y") { print "\nadded \n\n"; open (DEFS, ">>/Users/me/defs.txt") || die "Can't open files: $!"; print DEFS "$sw \t $_ \n"; close DEFS; } #} else { # print "Type in alternate spelling: "; # chomp (my $sw = <STDIN>); # if (/^.*?<p>.*?( $sw )/i) { # print "$sw \t $_ \n"; # print "Add this definition? "; # chomp (my $dec = <STDIN>); # if ($dec eq "y") { # print "\nadded \n\n"; # open (DEFS, ">>/Users/me/defs.txt") || # die "Can't open files: $!"; # print DEFS "$sw \t $_ \n"; # close DEFS; # } # } } } }