The output is a filecount of zero and no files were copied.
Brian
----- Original Message ----- From: "Wagner, David --- Senior Programmer Analyst --- WGO" <[EMAIL PROTECTED]>
To: "Wagner, David --- Senior Programmer Analyst --- WGO" <[EMAIL PROTECTED]>; "Brian Milbrandt" <[EMAIL PROTECTED]>; <beginners@perl.org>
Sent: Tuesday, April 19, 2005 5:31 PM
Subject: RE: Copy and rename files
Wagner, David --- Senior Programmer Analyst --- WGO wrote:Brian Milbrandt wrote:I think you really want $file and not $name, but still need to get right location. Also you need to do either a rename or mv otherwise you are only changing the name in $newfile, but not actually doing any work.I am trying to convert a unix script to perl. The script takes 2 command line arguments, source and target. I am unable to get the file copy and rename function working properly. Here is what I have that is not working properly.
$target is the target directory variable $source is the source directory variable
opendir DH, "/$target"; foreach $file (readdir DH) { printf " the file name is %s\n", $file; next unless $file =~ \/.abc$/ and !-z $name;
Wags ;)
Since you did not provide what really happens, I am assuming that you are not getting by ! -z $name. You have not done a chdir, so to get the actual file you will need to concatenate "/$target/" . $name for the test.
Wags ;)
my $newfile = /$target//$file; $newfile =~ s/\.abc$/.xyz/; $filecount += 1; }
******************************************************* This message contains information that is confidential and proprietary to FedEx Freight or its affiliates. It is intended only for the recipient named and for the express purpose(s) described therein. Any other use is prohibited. *******************************************************
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>