The operator -e (like the other -X operators) takes a filename or file
handle, and not a glob or file name pattern with wildcards. As others
pointed, you use the builtin glob to do the expansion (either explicitly
or via <>).

Then you might say:

for (glob 'file*') {
   print "true\n" if -e $_;
}

Note that if the glob was expanded, it is generally obvious that the file
exists (that is, -e $_ above will be true above). But if no filename
matching 'file*' was found, the function return 'file*' unchanged.

Regards,
Adriano.

--
dear all,

i am trying to check if there are any files named file* (e.g.
file_001.txt file1.doc) in my directory.

if( -e "file*" ) { print("true\n"); } # this doesn't work
else { print("false\n"); }

if( -e "m/^file/" ) { print("true\n"); } # this doesn't work either
else { print("false\n"); }

thank you in advance, any answer would be greatly appreciated.

-H.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


  • Re: file test Adriano Rodrigues Ferreira

Reply via email to