Re: Syntax Problem...
From: Clifford Bracht (beaton_at_franklincollege.edu)
Date: 01/09/04
- Next message: Bernard El-Hagin: "Re: joint venture"
- Previous message: Uri Guttman: "Re: Learning perl when in the frying pan..."
- In reply to: Paul Boardman: "Re: Syntax Problem..."
- Next in thread: J. Gleixner: "Re: Syntax Problem..."
- Reply: J. Gleixner: "Re: Syntax Problem..."
- Reply: Tad McClellan: "Re: Syntax Problem..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 9 Jan 2004 12:14:35 -0800
"Paul Boardman" <Paul.E.Boardman@umist.ac.uk> wrote in message news:<3ffe6eb4@news.umist.ac.uk>...
> "Clifford Bracht" <beaton@franklincollege.edu> wrote in message
> news:41e4115.0401081224.315618ae@posting.google.com...
> > I'm tring to write a script that verifies if the time of the last
> > modification is more recent than the time of the last access.
>
> <snip code>
>
>> Why are you opening the file and reading through it?
>
>
First off, Thank you to everyone for the suggestions and help.
I figured out a few of my mistakes shortly after I posted my message
and after working on the coding some I have come up with this:
#!/usr/bin/perl -w
#perl -w
$filename = "C:/temp/test.txt";
Set_File();
sub Set_File
{
open (FILEHANDLE, "<$filename") || die "Cannot open $filename,
err=\"$!\"\n";
if ($filename ne " \n")
{
$mtime = (stat ($filename))[9] || die "Sorry, cannot stat! \n";
Check_Mod();
}
}
sub Check_Mod
{
while(1)
{
$mtime_2 = (stat ($filename))[9] || die "Sorry, cannot stat! \n";
#View the two Mod times for test purposes.
print "previous_mtime = $mtime and mtime = $mtime_2 \n";
#Test to see if Modification have been made to file
if ($mtime_2 ne $mtime)
{
print "$filename has been modified.! \n";
Set_File();
}
else
{
print "$filename is OK. \n";
}
print "$filename is done testing. \n";
#sleep 60;
}
}
I have tested it and when I change the file it sends the correct
message and then runs through a new loop.
But it runs in an infinite loop that I would only like to run every 60
seconds, but when I put the code the line:
sleep 60; the script will not output anything??? Does anyone have any
suggestions. Do I have the sleep function in the correct place, or do
I need to go about this in a differe way??
I also don't know if I used proper Perl practices by calling the sub
routines the way that I did at the beginning and in the while loop, so
that might contribute to the problem?? Thanks
- Next message: Bernard El-Hagin: "Re: joint venture"
- Previous message: Uri Guttman: "Re: Learning perl when in the frying pan..."
- In reply to: Paul Boardman: "Re: Syntax Problem..."
- Next in thread: J. Gleixner: "Re: Syntax Problem..."
- Reply: J. Gleixner: "Re: Syntax Problem..."
- Reply: Tad McClellan: "Re: Syntax Problem..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|