Sprad has asked for the wisdom of the Perl Monks concerning the following question:

I want to have a generic copy function, with checks for existence, logging, etc. Part of it would be something like this:
if (-e $sourcefile)
Which works fine if $sourcefile is something like 'c:\foo.txt', but if we're doing a wildcard copy, $sourcefile might be 'c:\foo\*.*'. -e doesn't work on that, since (I assume) it's looking for a file literally named '*.*'.

Is there a trick to it?

---
A fair fight is a sign of poor planning.

Replies are listed 'Best First'.
Re: Filechecks with wildcards
by pbeckingham (Parson) on May 20, 2004 at 23:05 UTC

    Use the following if you'd like to expand the wildcards:

    my @files = glob 'C:\foo\*.*';
    But don't forget that the *.* junk is only necessary from the point of view of the DOS dir command, and it would be better to use the following, otherwise you require there to be a period in the filename:
    my @files = glob 'C:\foo\*';