You could try assigning the intended name to "$outfile" from the beginning:
use strict; my $infile = 'c:/RZ_Q.008'; # is it the same input file every time?
my $outfile = sprintf("%d.txt", time())
my ( $yr, $mo, $dy ) = (localtime)[5,4,3]; my $outfile = sprintf( "%04d%02d%02d.txt",$yr+1900,$mo+1,$dy ); # (I tend to format date-as-filename so that it will be # easy to sort file names chronologically: YYYYMMDD) # you can add hours and minutes, if you like -- check # `perldoc -f localtime`...
Now, the only issue is to control the scheduling for when the script gets executed (which is not a perl question, per se, unless you search for a "perl version of cron for ms-windows", or some such... but isn't there a scheduler utility that comes with ms-windows?)

Apart from that, the compulsive golfer in me sees a few places where you could simplify/condense the code a bit. I should restrain myself -- maybe you're just showing a subset of the whole application, and premature optimizations are a sin anyway, of course. But I can't resist...

# (assign $infile, $outfile as above, open IN, OUT as in your post, th +en: while (<IN>) { print OUT unless ( /774(0[346789]|1[123468])/ ); } # but if the set of numerics to exclude changes regularly, # you'll want to figure out how to convey the proper set # to the script on start-up, and construct a regex along the # lines shown in your original code.

In reply to Re: rename output file with system date by graff
in thread rename output file with system date by skyler

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.