foreach (@files) { /(prefix)(_)(\d+)(_)(\d+)(_)(\w+)(_)(\w+)(_)(\w+)(\.)(\w+)/; $filename = "$1$2$3$4$5$6$7$8$9$10$11$12$13"; print "name of file: $filename \n"; print "\n";<c>

That's ugly. You've been previously shown a much more compact and clear way to do this. Okay, we'll move on to the current question, but your failure to incorporate previous lessons does not bode well for future enlightenment.

use strict; use warnings; my $counter = 0; # get last step completed, if any my $file = glob("S*.txt"); if (defined $file) { ($counter) = $file =~ m/S(\d+)\.txt/; } printf "Ready to start step %d\n",++$counter; if ($counter == 1) { print "Just getting started.\n" } elsif ($counter > 1 && $counter <= 4) { print "All kinds of interesting intermediate processing goes on here +.\n" } elsif ($counter == 5) { print "Finishing up.\n" } print "Completed step $counter.\n"; stepfile($counter); # forget previous step, if any, now that this one is done unlink $file if (defined $file); sub stepfile { my $step = shift; my $filename = sprintf "S%06d.txt",$step; open my $tfh,'>',$filename; }

This differs some from the approach in your code, which creates all 5 step files first. This code looks for a single file containing the last completed step number to determine what step do next, does it, and when finished creates a file showing how far it got, and removes the last file.

But God demonstrates His own love toward us, in that while we were yet sinners, Christ died for us. Romans 5:8 (NASB)


In reply to Re: check for latest file, remove and touch file? by GotToBTru
in thread check for latest file, remove and touch file? by fasoli

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.