in reply to Test for file(s): glob or -e?
#! /usr/bin/perl -w $, = ', '; print $ARGV[0] =~ tr/*?// ? glob ($ARGV[0]) : ((-e $ARGV[0]) ? $ARGV[0 +] : '<No File>');
This was tested on Win32 so $ARGV[0] is not globbed by the OS.
Also try the following which atempts a glob followed by a single file test in case you were globbing a normal file name.
#! /usr/bin/perl -w $, = ', '; my @files = glob('*.txt'); print @files if -e $files[0];
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
•Re: Re: Test for file(s): glob or -e?
by merlyn (Sage) on Feb 18, 2004 at 15:27 UTC | |
by inman (Curate) on Feb 18, 2004 at 18:46 UTC |