
rjoseph
Novice
May 7, 2001, 1:55 PM
Post #2 of 8
(2611 views)
|
Ok, woah, here we go.
opendir ( DIR_tools,"c:/apples/tools") or die "opendir dir_apples/tools failed ; $!"; Why not check out the File::Find module from CPAN - it usually is a much better idea than surfing through a directory yourself.
copy ("c:/apples/tools/$name", "h:/apples/${this_Name}.${item_apples}/tools/$name"); I have never heard of a copy function in Perl (and there is no mention in any of the docs, so unless this is a sub you created (in which case you should have defintely posted that code here because we can't help with copying files if you don't show the file copying subs) then you might want to check into using something else. As for copying files, I find it easiest (and safest) to do this (supposing I am copying a.txt into b.txt):
my $buffer; open (A,"a.txt") or die "a.txt: $!\n\n"; open (B,"+>b.txt") or die "b.txt: $!\n\n"; binmode(A); binmode(B); while (read(A,$buffer,1024)) { print B $buffer; } close(A); close(B); Noticed the bolded binmode functions - those are important on certain OSes (I am assuming you are on Windows because of your directory naming scheme) that distinguish between text and binary files so that you dont accidently transfer a binary file in ASCII mode (bad bad bad). Hope this helps! r j o s e p h "Violence is a last resort of the incompetent" - Foundation
|