I think I made the correct change per your recommendation, but now I get this error: Global symbol "$ordernum" requires explicit package name at test.pl line 108.
$allmondayflag = 1; foreach my $orderfile (<$instance_root/order_temp/ord.*>) { print "\nProcessing Order File: $orderfile\n"; open (FILEH, $orderfile) or die "Could not open order file: $o +rderfile : $!"; while (my $line = <FILEH>) # loop as long as there are +records in the file { my $ordertype = substr($line, 0, 2); # used to fin +d the order header if ($ordertype eq "HM") # only look at the dates o +n the header records { my $ordernum = substr($line, 2, 7); my $date_str = substr($line, 64, 8); my ($year, $month, $day) = $date_str =~ m/ +(\d{4})(\d{2})(\d{2})/; my $time = timelocal("", "", "", $day, $month-1, + $year); # For $month: Jan = 0, Feb = 1, etc. if ((localtime($time))[6] == 1 ) # the order is + on a Monday { print " Order Number = $ordernum Order Date += $date_str is a Monday\n"; $allmondayflag = 1; next; # move onto the next record in the curren +t file } else { # We have found an order date that is not +a Monday $allmondayflag = 0; close FILEH; last; # bail out of the loop if date is not M +onday and process the next order } } # end of Ordertype IF } # end of while loop # Decide where to move the file based on the allMonday +Flag if ($allmondayflag) { print " Order Number = $ordernum has order dates th +at are all Mondays. This is a bad order file and is being moved to $b +adordpath\n"; move("$orderfile", $badordpath) or die "\nCould not + move the file $orderfile. Move failed: $!"; } else { print " Order Number = $ordernum Order Date = $date +_str is not a Monday.\n"; print " This file is valid and is being moved to $good +ordpath\n"; move("$orderfile", $goodordpath) or die "Could not move + the file $orderfile. Move failed: $!"; } close FILEH; # close file when we run out of lines to + read } # end of ForEach loop } else { my $where = "$instance_root/order_temp"; print "Directory $where does not exist...now exiting\n\n"; }

In reply to Re^4: Seeking help with Looping problem by sasrs99
in thread Seeking help with Looping problem by sasrs99

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.