in reply to Re: Test for file(s): glob or -e?
in thread Test for file(s): glob or -e?

But * and ? are valid filename characters, so how can you know if I was giving you a literal filename, or a glob?

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

  • Comment on •Re: Re: Test for file(s): glob or -e?

Replies are listed 'Best First'.
Re: •Re: Re: Test for file(s): glob or -e?
by inman (Curate) on Feb 18, 2004 at 18:46 UTC
    My Windows background has found me out...
    $, = ', '; my @files; print ((-e $data)? $data : ((@files = glob $data) && ($data ne $files[ +0]))? @files : ()) if $data;

    Prints $data if $data is a file. Prints the globbed $data only if the glob did some work. The whole statement is protected just in case $data is empty.