athanasia has asked for the wisdom of the Perl Monks concerning the following question:
This works if the script is executed in the directory where the files reside, but does not work in any other directory. Is there a solution using similar syntax or I have to rewrite it in a more verbose way (e.g. creating the list of files and then with a foreach loop, unlink "${dirname}/${filename}")?opendir (DIRHANDLE, "/path/of/dir") or die "Cannot open directory $!\n +"; unlink grep (/$mypattern/i, readdir DIRHANDLE); closedir DIRHANDLE;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Unlink files but not in pwd
by kyle (Abbot) on Mar 27, 2009 at 16:05 UTC | |
|
Re: Unlink files but not in pwd
by baxy77bax (Deacon) on Mar 27, 2009 at 15:55 UTC | |
by athanasia (Pilgrim) on Mar 27, 2009 at 16:23 UTC | |
by drench (Beadle) on Mar 27, 2009 at 22:15 UTC | |
|
Re: Unlink files but not in pwd
by Illuminatus (Curate) on Mar 27, 2009 at 15:52 UTC | |
by athanasia (Pilgrim) on Mar 27, 2009 at 16:01 UTC | |
by Illuminatus (Curate) on Mar 27, 2009 at 16:07 UTC | |
|
Re: Unlink files but not in pwd
by grinder (Bishop) on Mar 27, 2009 at 20:38 UTC |