in reply to Re: Unlink files but not in pwd
in thread Unlink files but not in pwd

Hi baxy77bax,

Very true :-). However, this kind of implies that I cannot delete the whole list @l at once and using a foreach loop is inevitable. Anyway, don't know why I insist so much on a one-liner, I am usually quite verbose when coding.

Thanks,
Athanasia

Replies are listed 'Best First'.
Re^3: Unlink files but not in pwd
by drench (Beadle) on Mar 27, 2009 at 22:15 UTC
    You can avoid the foreach if you use map:
    opendir(my $dh, './dir') || die "opendir: $!"; unlink map { "./dir/$_" } grep { /$mypattern/i } readdir $dh; closedir $dh;