in reply to Re: Best way to remove elem of for loop
in thread Best way to remove elem of for loop
You could use a do block to avoid having the -d directory test twice.
$ ls -F fred testFBF* xxx/ yyy/ $ perl -Mstrict -Mwarnings -E ' my @dirs = qw{ fred testFBF xxx yyy }; @dirs = map { -d $_ ? $_ : do { warn qq{Not a directory: $_\n}; () } } @dirs; say qq{Directories: @dirs};' Not a directory: fred Not a directory: testFBF Directories: xxx yyy $
I hope this is of interest.
Cheers,
JohnGG
|
|---|