I'm on my day off, so I can't test this, but it should get you started.

############################

use File::Copy;

#Get the date variables based on system time

($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
@months = qw(00NUL 01JAN 02FEB 03MAR 04APR 05MAY 06JUN 07JUL 08AUG 09SEP
10OCT 11NOV 12DEC); #populate the @months array
$year += 1900;# $year is now 4-digit year
$year2digit = sprintf("%02d",$year); #convert to 2 digits
$mon += 1;

#IF NOT EXIST e:\reports\REJECTS-%mm%%dd%%yyyy%.psr GOTO FILEZIP

if(!-e "e:\\reports\\REJECTS-$mon$mday$year.psr"){
   system("PKZIPC -add e:\\tepcbkup\\AG$mon$mday$year2digit
c:\\prod\\output\\*.*");
   #I didn't know exactly what pkzipc does, so I did a system call
}

#COPY e:\reports\REJECTS-%mm%%dd%%yyyy%.psr c:\prod\output\ 

copy("e:\\reports\\REJECTS-$mon$mday$year.psr","c:\\prod\\output\\REJECTS-$m
on$mday$year.psr");

#MOVE e:\tepcbkup\AG%mm%%dd%%yy%.zip e:\tepcbkup\%mth%\ 

copy("e:\\tepcbkup\\AG$mon$day$year2digit.zip","e:\\tepcbkup\\$months[$mon]\
\AG$mon$day$year2digit.zip");
if(-e "e:\\tepcbkup\\$months[$mon]\\AG$mon$day$year2digit.zip"){
   unlink("e:\\tepcbkup\\AG$mon$day$year2digit.zip");  
   #I can't remember the move function off the top of my head
   #so I copied, checked for the dest file, and deleted the source file
}

#IF NOT EXIST c:\prod\output\*.psr GOTO DAT_DEL
if(!-e ","c:\\prod\\output\\REJECTS-$mon$mday$year.psr"){
  unlink("c:\\prod\\output\\email.dat");
}else{
   #DEL c:\prod\output\*.psr

   #You will want to use glob here, probably, but I can't 
   #remember the syntax off the top of my head, so...

   opendir(DIR,"c:\\prod\\output");
   chdir("c:\\prod\\output");
   @files = readdir(DIR);
   foreach $file(@files){
      if($file =~ /\.psr$/i){ #if file ends with .psr
         unlink $file;
      }
   }
}




-----Original Message-----
From: Auernheimer, Rebecca (CORP, Consultant)
To: 'Wagner-David'; [EMAIL PROTECTED]
Sent: 3/22/02 11:25 AM
Subject: RE: usefulness of perl for production?

I appreciate the replies so much.  I start out with a command line like
this: "backup.bat mm dd yy yyyy"
where mm is the 2-digit month, dd is the 2-digit day, yy is the 2-digit
year, and yyyy is the 4-digit year.  Those are my variables, as I
suppose
they would be called. (Besides some programming as a kid on my commodore
64
computer, MS-DOS is my first exposure to programming.)  I am using
ActivePerl 5.6.
Here is the MS-DOS code that I want to write in perl:

SET mm=%1
SET dd=%2
SET yy=%3
SET yyyy=%4

:CHECKPSR
IF NOT EXIST e:\reports\REJECTS-%mm%%dd%%yyyy%.psr GOTO FILEZIP

:PSRCOPY
COPY e:\reports\REJECTS-%mm%%dd%%yyyy%.psr c:\prod\output\ 

:FILEZIP
PKZIPC -add e:\tepcbkup\AG%mm%%dd%%yy% c:\prod\output\*.* 

:ORGANIZE
IF "%mm%"=="01" SET mth=01JAN
IF "%mm%"=="02" SET mth=02FEB
IF "%mm%"=="03" SET mth=03MAR
IF "%mm%"=="04" SET mth=04APR
IF "%mm%"=="05" SET mth=05MAY
IF "%mm%"=="06" SET mth=06JUN
IF "%mm%"=="07" SET mth=07JUL
IF "%mm%"=="08" SET mth=08AUG
IF "%mm%"=="09" SET mth=09SEP
IF "%mm%"=="10" SET mth=10OCT
IF "%mm%"=="11" SET mth=11NOV
IF "%mm%"=="12" SET mth=12DEC

MOVE e:\tepcbkup\AG%mm%%dd%%yy%.zip e:\tepcbkup\%mth%\ 

:CHK_PSR
IF NOT EXIST c:\prod\output\*.psr GOTO DAT_DEL

:PSR_DEL
DEL c:\prod\output\*.psr 

:DAT_DEL
DEL c:\prod\output\email.dat

(end code)

If someone felt like writing that out in perl, I would be ecstatic.
Thanks,
Rebecca
-----------------------------------------------------------------

-----Original Message-----
From: Wagner-David [mailto:[EMAIL PROTECTED]]
Sent: Friday, March 22, 2002 10:46 AM
To: Auernheimer, Rebecca (CORP, Consultant); [EMAIL PROTECTED]
Subject: RE: usefulness of perl for production?


        Yes Perl is very useful for doing the work stated, but the group
needs to know from either a script you want to change or showing some
code
you desire to change, so they can assist and hopefully point you in the
right direction.

        move,copy,rename can be handled by File::Copy
        zip files        can be handled by Archive::Zip

        I have attached a reply from Tmothy Johnson from this week.

        The list can be very helpful, but the best you can do is provide
more detail and/or code, so the list can respond without guessing.

Wags ;)

-----Original Message-----
From: Auernheimer, Rebecca (CORP, Consultant)
[mailto:[EMAIL PROTECTED]]
Sent: Friday, March 22, 2002 09:26
To: [EMAIL PROTECTED]
Subject: usefulness of perl for production?


Hello all,
I want to use perl to replace our MS-DOS batch jobs.  The main purpose
of
most of these batch jobs is to move, copy, rename, and zip files in a
windows (NT) environment.  I use a few variables to add the date into
the
zip file name and to move the zip file into the appropriate month-named
directory.  I am having trouble finding information on getting perl to
handle these (overly?) simple functions.  I want to start very small and
gradually build on my knowledge to do more complicated things.  I have
started reading Learning Perl (2nd ed) and I was overwhelmed, partially
because the topics I wanted to cover were not addressed.  Someone
suggested
looking into the "system" command so I scanned chapter 14, but it does
not
seem to address my needs, either.  I looked at some web sites (perl.org,
cpan, perl.com, webmonkey) without finding what I needed.

My questions:
Is perl appropriate for the tasks I mentioned in the second sentence?  
If so, where can I get information about how to do those things?

Thank you so much for any input you can give me.
Rebecca

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


--------------------------------------------------------------------------------
This email may contain confidential and privileged 
material for the sole use of the intended recipient. 
If you are not the intended recipient, please contact 
the sender and delete all copies.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to