How can I test if a filename matching a pattern exists in Perl?

Viewed 32427

Can I do something like this in Perl? Meaning pattern match on a file name and check whether it exists.

    if(-e "*.file")
    {
      #Do something
    }

I know the longer solution of asking system to list the files present; read it as a file and then infer whether file exists or not.

3 Answers

On Windows I had to use File::Glob::Windows as the Windows path separating backslashes don't seem to work perl's glob.

Related