[Chicago-talk] working with a revolving number

Dooley, Michael Dooley.Michael at con-way.com
Wed Mar 10 10:19:17 CST 2004


ok guys n` gals,

I got a question.

we generate files w/ a sequential 3 digit number as an extension up to 999
then it starts at 000 again.
IE: a.000 b.001

for this particular example the files MUST be in that order. A before B.
sometimes B comes before A.

1) this presents a problem.
2) I have to move the files to a new filename based on this order.
3) how would you go about coding for the anomaly (when B comes before A)
since the max # could be 999.

This is the code I use currently (I fix the anomaly by hand when I get an
error via email)

        if (/q245/) {
                my @itx=grep /q245944/ && !/ITX$/, @files;
                my @iss=grep /q245846/ && !/ISS$/, @files;
                my @d=grep /q245945d/, @files;

                for (@itx) { my ($date)=date(); $ftp->put("$_",
"$_.$date.ITX") ; ftp_log($cli_code, $_, "$_.$date.ITX") };
                for (@iss) { my ($date)=date(); $ftp->put("$_",
"$_.$date.ISS") ; ftp_log($cli_code, $_, "$_.$date.ISS") };
                for (@d) {
                        my ($date,$microsec)=date();
                        my (undef, $number)=split(/\./);
                        $number++;
                        $ftp->put("$_", "${date}${microsec}.SPD");
                        ftp_log($cli_code, $_, "${date}${microsec}.SPD");
                        $ftp->put("q245945h\.$number",
"${date}${microsec}.SPH");
                        ftp_log($cli_code, "q245945h\.$number",
"${date}${microsec}.SPH");
                }
        }


I was thinking about doing an if statement that says if file B does not
exhist then $number-- then ftp the file. but then I came to think about the
revolveing number and what kinda issues that could cause.

Kinda curious what sagely advice you could offer.

Mike



More information about the Chicago-talk mailing list