Sadmachine has asked for the wisdom of the Perl Monks concerning the following question:
As far as I can tell the above code should work. I know that opendir uses the correct directory, I know that a list of files is created (@allfiles) and that @onlyfile is a list of files minus the dot files. The only bit that doesn't work is the unlink part. Can anyone tell me why? Thanksopendir(DIR, "$basedir/$mesgdir"); @allfiles = readdir(DIR); @onlyfiles = grep {!/^\./} @allfiles; foreach $file (@onlyfiles) { unlink ($file); } closedir(DIR);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Deleting specified files and directories
by MeowChow (Vicar) on May 14, 2001 at 12:09 UTC | |
|
Re: Deleting specified files and directories
by Corion (Patriarch) on May 14, 2001 at 12:03 UTC | |
|
Re: Deleting specified files and directories
by Eureka_sg (Monk) on May 14, 2001 at 12:11 UTC | |
by Sadmachine (Novice) on May 14, 2001 at 12:36 UTC |