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;

In reply to Series of REGEX with OR by wrkrbeee

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.