[rochester-pm-list] Script won't run on Perl Version 4 :-(

Charles Rishel charles at mckeanmachinery.com
Fri Mar 3 07:52:39 CST 2000


Hi everyone,

About 2 weeks ago I posted a script that I made to delete image files from a directory, reading the list of files to delete from a text file.
This works beautifully on Perl Version 5, which one of our web-servers uses, and I have ActivePerl V5 on the Windows machine to automate
the process on my workstation.  But our other web-server is utilizing Perl Version 4, and the script aborts at line 22 (at the call for chomp(  )
and I have no clue of the differences between Perl V4 and Perl V5.  If anyone can provide me with some pointer as to where I can find the 
information that I need to fix this problem, I would be very grateful.
I will repost the script again for reference.
Thanks,

Charles K. Rishel
IT Manager
McKean Machinery Sales
http://www.mckeanmachinery.com

#!/bin/perl

#This program created by Charles K. Rishel
#Why??
#1.  I got tired of manually deleting up to 200 images from our Web-Server.
#2.  Why not?

#This program will read a list of files to delete from an input file,
#and remove the files contained in that file, from the current dir.

$infile="remove.txt";	#variable to hold the input filename.
$countallfiles=0;   	#variable to hold the number of files in list
$count=0;   	  	#variable to hold the number of files deleted

open(IN,$infile)|| die "cannot open $infile for reading: $!\n"; 	 #opens the input file

while(<IN>)		  	#loop until end of $infile is reached, reading each line of text.
{  
   $countallfiles++;	#This increments the file counter for all files in list
   s/  00//;		#This code is remarked below.
   $filename=$_;
   chomp($filename);
   $filename="$filename.jpg";

   if (unlink($filename)>0)
   {
      $count++;		#This increments the file counter for deleted files
   }

#The following code will print all filenames not deleted.
#not necessary for my purposes, so commented out.

#   else
#   {
#       print "cannot delete $filename: $!\n";
#   }

}
print "$count of $countallfiles files deleted.\n";



#The following code is used to remove the 2 spaces and 2 leading zero's from
# the input data file, and append the .jpg extension making a valid image filename.

#   s/  00//;		#removes the spaces between the supplier and item# leading 0's
#   $filename=$_;		#variable to hold the new string, now in file format
#   chomp($filename);	#remove the null character at end of string
#   $filename="$filename.jpg";    #append .jpg to the end of the string

#The input file data AT  001401, comes through this process as AT1401.jpg, and this filename
#can then be used to remove the applicable file.  The nice part is that if you already have a
#list containing valid filenames such as AT1401.jpg, you can eliminate the step to add the 
#extension, and all will be fine.


-
For information on unsubscribing from this list, please visit http://rochester.pm.org



More information about the Rochester-pm mailing list