Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Filechecks with wildcards

by Sprad (Hermit)
on May 20, 2004 at 22:49 UTC ( [id://355114]=perlquestion: print w/replies, xml ) Need Help??

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\*';

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://355114]
Approved by pbeckingham
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2025-05-23 02:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.