This is *UNTESTED* but it should come close to what you want:
#!/usr/bin/perl use warnings; use strict; use lib "/opt/perl/lib/site_perl/5.6.1/Mail"; use Mail::Sender; use File::Basename 'basename'; use POSIX 'mktime'; my $instance = 'natt1'; my $instance_root = "/opt/manu/manu71/transport/$instance"; my $goodordpath = "$instance_root/order_good"; my $badordpath = "$instance_root/order_bad"; my $where = "$instance_root/order_temp"; print "\n\n*** Starttime = " . localtime . " ***\n\n"; -d $where or die "Directory $where does not exist...now exiting\n\n"; print "Directory $where exists. Directory check was successful.\n\n"; # find the number of files we are to process # if there are no files to process, bail @ARGV = <$where/ord.*> or die "\nThere are no files to process. Now ex +iting.\n"; print 'Processing ' . @ARGV . ' order file', @ARGV == 1 ? '' : 's', ". +\n"; my ( $ordertype, $ordernum, $date_str, $time ); while ( <> ) { print "\nProcessing Order File: $ARG\n" if $. == 1; if ( /^HM(.{7})/ ) { $ordernum = $1; $date_str = substr $line, 64, 8; my ( $year, $month, $day ) = $date_str =~ /(\d{4})(\d{2})(\d{2 +})/; $time = mktime( 0, 0, 12, $day, $month - 1, $year - 1900 ); + # For $month: Jan = 0, Feb = 1, etc. } if ( ( localtime $time )[ 6 ] != 1 ) { print " Order Number = $ordernum Order Date = $date_str is + not a Monday. This file is OK to move and process.\n"; my $file = basename $ARGV; # save the file name before closin +g it! close ARGV; # close the file before moving it! rename "$where/$file", "$goodordpath/$file" or die "Could not +move the file $file. Move failed: $!"; next; } if ( eof ) { print " Order Number = $ordernum has order dates that are al +l Mondays. This is a bad order file and is being moved to $badordpath +\n"; my $file = basename $ARGV; # save the file name before closin +g it! close ARGV; # close the file before moving it! rename "$where/$file", "$badordpath/$file" or die "\nCould not + move the file $file. Move failed: $!"; } } print "\n*** Endtime = " . localtime . " ***\n\n";

In reply to Re: Seeking help with Looping problem by jwkrahn
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.