You're right. 
Thank you so much for pointing it out.
I highly appreciate your help.

Loan

--- Timothy Johnson <[EMAIL PROTECTED]> wrote:
>  
> I think your problem is this line:
> 
> next if $file =~ /\./;
> 
> Any file that has a period in the name will not be
> removed.  I'm assuming
> that what you wanted to do was skip . and ..  If
> that is the case, then try
> something more like this:
> 
> next if $file =~ /^\.{1,2}$/;
> 
> -----Original Message-----
> From: loan tran
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Sent: 4/5/02 6:17 PM
> Subject: Re: Can Unlink Remove Tar and Zip files?
> 
> This is how i use the unlink. Please take a look.
> Thanks.
> -----------
> 
> #!/usr/bin/perl 
> # clean old file
> 
> use Carp;
> 
> $cur_time = time;   # current time in epoch (in
> seconds)
> $dir = '/opt/sybase/OCT/dump/';
> $hour = 10 ;
> 
> opendir DIR, $dir || die "Failed to open $dir: $!";
> 
> my @files = readdir DIR;
> closedir DIR;
> unless ($cnt = @files) {
>  print "No file to rm.\n";
>  return;
> }
> 
> foreach $file (@files) {
>         next if $file =~ /\./;
> 
>         ($dev, $ino, $mode, $nlink, $uid, $gid,
> $rdev,
> $size, $atime, $mtime, $ctime, $blksize, $blocks) =
> stat $file;
> 
>         $fage = ($cur_time - $mtime) / 3600; # file
> in
> hours (note: 1 hr = 3600 sec)
> 
>         print "file found: $file ($fage hr)\n";
> 
>         if ($fage > $hour) {
>                 printf "\nDelete file older than
> $hour
> hrs : %4s  %.2f hrs old\n", "$dir"."$file",$fage;
>                 $rc = unlink "$dir"."$file" ;
>                 $stat = $rc ? "success" : "failed";
>                 print "\t$file remove status:
> $stat.\n";
>         } 
>         else {
>                 printf "Too young: %15s [%.2f
> hr]\n",
> $file, $fage;
>         }
> }
>         opendir DIR, $dir || die "Failed to open
> $dir:
> $!";
>         my @files = readdir DIR;
>         $cnt2 = @files;
> 
>         print  "\nTo remove all files that are older
> than $hour in directory: $dir\n";
>         printf "Before delete: %5d\n", $cnt;
>         printf "Files deleted: %5d\n", $cnt - $cnt2;
>         printf "After delete : %5d\n", $cnt2;
>         closedir DIR;
> 
>         
> --- drieux <[EMAIL PROTECTED]> wrote:
> > 
> > On Friday, April 5, 2002, at 05:14 , loan tran
> > wrote:
> > [..]
> > > I want to remove *.tar and *.Z file too.
> > >
> > > Any suggestions?
> > 
> > how were you building your list of files to be
> > removed?
> > 
> > i just built both *.tar and *.Z files and was able
> > to
> > remove them with a perl script using the methods
> > listed
> > in
> > 
> >     perldoc -f unlink
> > 
> > 
> > 
> > ciao
> > drieux
> > 
> > ---
> > 
> > 
> > -- 
> > To unsubscribe, e-mail:
> > [EMAIL PROTECTED]
> > For additional commands, e-mail:
> > [EMAIL PROTECTED]
> > 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Tax Center - online filing with TurboTax
> http://taxes.yahoo.com/
> 
> -- 
> 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.


__________________________________________________
Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax
http://taxes.yahoo.com/

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

Reply via email to