Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

copy file wildcard syntax

Status
Not open for further replies.

new2unix

Programmer
Feb 5, 2001
143
US
Hi,

I may have some syntax error with the copy statement. Basically, I need to copy all files from the source directory that has "CAD" as part of the filename with extension ".ssc" to the destination directory. So far, the script is not working.


#!/usr/local/bin/perl -w

use File::Copy;

$source_dir = "/usr/tables";
$source_tbl = "Test_Table/bak";

$dest_dir = "/usr/tables";
$dest_tbl = "Test_Table2/bak";

copy("$source_dir/$source_tbl/*CAD*.ssc", "$dest_dir/$dest_tbl/.");


Thanks

Mike
 
Mike,

I don't think copy() works with wildcards.

I would try something like this:

@files = glob("$source_dir/$source_tbl/*CAD*.ssc");

foreach (@files) {
copy("$_","$dest_dir/$dest_tbl/.");
}

I do work on NT, but this should not matter.

AD AUGUSTA PER ANGUSTA

Thierry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top