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
In reply to Re^2: Best way to remove elem of for loop
by johngg
in thread Best way to remove elem of for loop
by HarryPutnam
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |