in reply to Find a file in a list of directories
more compact version of your code. And you should use '-e' test instead of '-t'
#!/usr/bin/perl sub FileFinder { my ($target, @dir) = @_; return (grep {-e $_} map {"$_/$target"} @dir)[0]; } open(F, FileFinder('FileFinder.pl', qw(some/ dirs/ ./)) || die "File n +ot found") or die $!;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Find a file in a list of directories
by demerphq (Chancellor) on May 06, 2002 at 16:50 UTC |
In Section
Cool Uses for Perl