wrkrbeee has asked for the wisdom of the Perl Monks concerning the following question:
Hi Perl Monks, have a series of regexs that work great until I impose a series of OR conditions. I receive an error stating "use of uninitialized value for $url_sub at line 45." Excluding the OR series eliminates the error, so I'm not sure how the ORs create an error. Grateful for any ideas. Thanks!
while (my $line = <$FH_IN>) { chomp $line; #removes line break or new line; my $url_sub = ""; print "processing file $counter,\n"; # Within each record, loop until a match occurs with "subsid" in the r +ecord,; # and the record contains a URL address, and the URL contain a derivat +ive; # of Exhibt 21, e.g., ex21, ex-21, exhibit21, or exhibt-21; + while ($line =~ m/subsidiar/igm && $line =~ m/\/Archives(.* +)">/igm && ($line =~ m/ex21/igm || $line =~ m/EX\-21/igm || $line =~ m/exhibit\-21/igm || $line =~ m/exhibit21/i +gm) ) { $url_sub = $1; #extract the match and assign to var +iable; #Join the match with the standard URL prefix; my $url = join("",$base_url,$url_sub); print $url; open my $FH_OUT, '>>',$write_dir or die "Can't open fi +le $write_dir >:$!>"; print $FH_OUT "$url\n"; ++$counter; } #End of while loop for extracting matching text; } #End of record;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Series of REGEX with OR
by NetWallah (Canon) on Apr 27, 2016 at 17:23 UTC | |
by wrkrbeee (Scribe) on Apr 27, 2016 at 17:24 UTC | |
by Preceptor (Deacon) on May 04, 2016 at 13:16 UTC | |
|
Re: Series of REGEX with OR
by hippo (Archbishop) on Apr 27, 2016 at 19:04 UTC | |
|
Re: Series of REGEX with OR
by Not_a_Number (Prior) on Apr 27, 2016 at 17:24 UTC | |
by wrkrbeee (Scribe) on Apr 27, 2016 at 17:29 UTC | |
|
Re: Series of REGEX with OR
by talexb (Chancellor) on Apr 27, 2016 at 17:19 UTC | |
by wrkrbeee (Scribe) on Apr 27, 2016 at 17:23 UTC |