in reply to file copy undefined?
Update: Missed the second part of the question. When you use strict;, you must explicitly declare each variable with my. You also appear not to be using copy correctly. Working code:
use File::Copy; use strict; use warnings; my $dirpath="C:\\inetpub\\performancetesting\\output\\new\\mlx\\aar"; my $dirpath2="c:\\temp"; opendir(IN,"$dirpath") or die "opening directory failed:$!"; while (defined (my $file = readdir(IN)) ) { my @files = split / /,$file; foreach my $filename (@files) { copy ("$dirpath".$filename, "$dirpath2".$filename) or warn "Ca +n't open the file yet $filename\n:$!"; open INPUT, "<", $dirpath.$filename or die "Open failure: $!"; until (eof(INPUT)) { chomp(my $line = <INPUT>); # print contents of the file or do anything print "$line"; } close INPUT; } } closedir(IN);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: file copy undefined?
by grashoper (Monk) on Apr 14, 2009 at 16:27 UTC | |
by kennethk (Abbot) on Apr 14, 2009 at 16:32 UTC | |
by FunkyMonk (Bishop) on Apr 14, 2009 at 16:55 UTC | |
by grashoper (Monk) on Apr 14, 2009 at 17:22 UTC |