Re: looping questions
- From: Joe Smith <joe@xxxxxxxxx>
- Date: Sat, 29 Sep 2007 04:07:11 -0700
lerameur wrote:
Hello,
this is not a perl problem (maybe it is). The function does work, but
gave me error . there are 4 files into the traffic directory, the loop
goes into 24 possiblility, copies the four files and gives me 20
errors. I decided to add an IF statement to only copy if the file
exists. what is wrong with my IF loop ?
You're not using glob() in the right context, and you've
got `...` where you should be using "...".
for my $hours ('00'..'23') {
$file23 = glob("$timestamp2$hours*") ;
print "$timestamp2: " ,$timestamp2, "\n";
print "file23: " ,$file23, "\n";
if ($file23 == 1){
system(`cp /input/fttr/traffic/$file23 /input/$Out_directory `);
}
$hours++;
}
for my $hours ('00' .. '23') {
my @files = glob "$timestamp2$hours*";
print "Found ",scalar(@files)," matching file(s) for $hours\n";
if (@files) {
my $cmd = "cp -p /input/fttr/traffic/$timestamp2$hours* /input/$Out_directory";
print "$cmd\n";
system $cmd == 0 or warn "Failed: $? $!";
}
}
-Joe
.
- References:
- looping questions
- From: lerameur
- looping questions
- Prev by Date: Re: SOAP timing out
- Next by Date: Re: string concatentation vs. interpolation: which one is more optimal?
- Previous by thread: Re: looping questions
- Next by thread: using IPC::Open3 to write to *and* read from a process...
- Index(es):
Relevant Pages
|