> Please accept my apologies for being so dumb.  

Not required.

> I am a beginner and really have done basic perl
> scripting by using the "copy and paste and modify"
> method of script writing.

Beginners learn by whatever means pleases them.
Examining other people's code is quite a good method,
upto a point.  Then asking for help, and reading the
documentation helps.

> I have a server running Solaris 8. From what I can
> determine, perl is version 4 on it (perl -v). Server
> came preinstalled with proprietary software for
> managing ads in our production dept.

Quote:

'Tim Christiansen suggested I use "dead flea-bitten
camel carcasses" instead of "Perl4", to highlight that
anything before version 5 is dead and has been
abandoned by most, I was tempted' - Jeffy Friedl
- Mastering Regular Expressions (last printed 1998)

:Unquote

You might want to try upgrading it, although I've got a
HP9000/715/100 with Perl version 4.00.  If required,
I shall turn it on for some exercise...

> I have a newly created directory that contains links
> to what will soon be thousands of files.  The number
> of links in this directory will grow daily.

Okay, that is clear.

> I am trying to write a simple perl script that can be
> automatically run by a cron that will delete these
> links after 3 days.  I "borrowed" a script that runs
> successfully on a Linux server here and does exactly
> the same thing.

Okay, so this is more a backwards port than anything
else.  Problem seems simple enough.

> Could someone look at this script and tell me where
> to begin debugging it.  When I run it in a command
> window, I get a server error "dir_prefix is not
> defined". 

Not so dumb after all, you beg for help, explain your
problem clearly, and some dumb person like me comes
along to help!

Having just gone through the code, I can't see anything
obviously wrong... AFAIK Perl 4 had a few differences,
but not where you point them out.  Can you upgrade Perl
if you wanted to, or would you care for me to debug this
on my HPUX box?

PS: use strict isn't going to work... Perl 4 didn't have
the keyword "use" AFAIK - let alone 'strict'.

Jonthan Paton

----------------------------------
Let me reformat the code the way I like :)  Also, I've
changed some bits - hopefully they work on Perl 4.


#!/usr/bin/perl -w

# Directory to work on
$dir_prefix = "/directoryoffroot/debbietest";

# Subject line of mail
$subject    = '"Kill the links"';

# Get directory information
opendir(FOTODIR, $dir_prefix) || die "Can't open: $!";
@directory=grep(!/^\./, readdir(fotodir));
closedir(FOTODIR) || die "Can't close: $!"; # Some guy
forgot to
                                              put this in
the
                                              original
code!

# Create a report file
open(rep_fil, ">/fotorep.txt") || die "Can't open: $!";

# Start our report
print rep_fil "  The following files deleted because they
were
1 days old...\n\n";

# Delete each file, and report what we've done
foreach $dir_entry (@directory) {
   $file_name = "$dir_prefix/$dir_entry";
   $file_days = (-M $file_name);
   if ($file_days > 1)
   {
      system("rm -f -r \"$file_name\"");
      print rep_fil "$file_name\n";
   }
}

# Finish the report
print rep_fil "\n            ***END OF REPORT***";
close(rep_fil) || die "Can't close: $!";

# Send email to root
system("mail -s $subject root\@whatever.com < /fotorep.txt");

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

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

Reply via email to