NYIMI Jose (BMB) wrote:

Is this a joke ? :-)

Here's a typical diff output:

17,18d16
< (who writes under the
< pseudonym "Omniscient Trash")
45,46c43,44
< soon every Tom, Dick or Harry
< will be writing his own Perl book
---


soon every Tom, Randal and Larry
will be writing their own Perl book


69a68,69


Copyright (c) 1998, The Perl Journal.
All rights reserved.





Don't use diff with the actual files!, use diff to compare the file listing that dives "ls". Here is my code (this script is called every 10min from crond):

#!/usr/bin/perl -w


# Store the new file listing system("ls -lR /home/originals > /tmp/Originals_PDF/pdflist.2");

# If ther's an older listing,
if( -r "/tmp/Originals_PDF/pdflist.1")
{
# Create a diff file that contains the diference between listings
system("diff /tmp/Originals_PDF/pdflist.1 /tmp/Originals_PDF/pdflist.2 > /tmp/Originals_PDF/pdf.diff");
open (FD, "/tmp/Originals_PDF/pdf.diff");
# Foreach file in the diff
while(<FD>)
{
if (/^\>/) # If they start with > (a new file)
{
push @originals, $_;
}
}
close(FD);
unlink("/tmp/Originals_PDF/pdf.diff");
}


# Update the listing
system("cp /tmp/Originals_PDF/pdflist.2 /tmp/Originals_PDF/pdflist.1");

# If we find a newly-added file, we send an e-mail
if(defined (@originals))
{
open (MAIL, "|mail -s '---Notificacio creacio PDF' [EMAIL PROTECTED]");
print MAIL "Listing of newly added files::\n\n";
foreach $arxiu (@originals)
{
print MAIL "$arxiu";
}
close(MAIL);
}





-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to