>  The part of the code below does not do this, saying "no such path or 
directory".
Thanks
 
opendir DIR, $dat0 or die "opendir $dat0: $! ($^E)";
while ($_ = readdir DIR) {
    next if -d $_;
    print "unlink $_";
    unlink $_, or warn "unlink $_' failed: $! ($^E)";
}
closedir DIR;

Rember, readdir does not prepend teh dir path to the file name:
 The part of the code below does not do this, saying "no such path or 
directory".
Thanks
 
opendir DIR, $dat0 or die "opendir $dat0: $! ($^E)";
while ($_ = readdir DIR) {
    my $file = $dat0 . '/' . $_;
    next if -d $file;
    print "unlink $file";
    unlink $file, or warn "unlink $file' failed: $! ($^E)";
}
closedir DIR;

It's a little unusual to use $_ that much - in general, 'magic vars' (like 
$_ and the match vars $1, $2 etc) should be moved to a named var if you're 
going to use them more than once or twice. It makes the code more readable 
and you're less likely to fool yourself.

a

-------------------
Andy Bach
Systems Mangler
Internet: [email protected]
Voice: (608) 261-5738; Cell: (608) 658-1890

Truth is eternal, knowledge is changeable.
It is disastrous to confuse them. 
-- Madeleine L'Engle
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to