The subref is of course overhead, but you might want to keep it as named sub for multiple use.Or just eliminate it entirely using a do-block instead of indirecting it with a subroutine:
my $dir = shift; my @list = grep /\.java$/ , do { if (opendir my $dh, $dir) { my @l = readdir $dh; closedir $dh; @l; } else { () } };
-- Randal L. Schwartz, Perl hacker
In reply to •Re: Re: globing directory names with spaces
by merlyn
in thread globing directory names with spaces
by abhishes
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |