I have tried out your recommendation and it works perfectly. The only thing I edited was the "my $filename = sprintf "S%05d.gro",$mdstep;" at the end, so that the step filename is always made up from 6 characters in total, including the S in the beginning.
I have a few questions though, the biggest of which comes from the fact that I started this thread with a panicky confusing message. My total steps aren't 5, in fact we don't know how many we will be needing to do, so it can be any number. So the numbers you have used, 4 and 5, are great for me to check the example but I have to now ask if you can explain how to write this bit having in mind that we don't know how many steps we'll do.
In other scripts I've written, I had done something like this when I needed to use a counter:
my $start; my $total; for ($start=0; $start<=$total; $start++) { #do stuff in the loop }
Does this make sense if $total is undefined? Of course if $total is undefined and the total number of steps is unknown, this bit...
elsif ($counter == 5) { print "Finishing up.\n" }
...is redundant, right?
Again thank you very much for your help, it's greatly appreciated :)
In reply to Re^2: check for latest file, remove and touch file?
by fasoli
in thread check for latest file, remove and touch file?
by fasoli
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |