Re: looping questions
- From: Jim Cochrane <allergic-to-spam@xxxxxxxxxxxxxxxxxxx>
- Date: Fri, 28 Sep 2007 22:38:58 +0200 (CEST)
On 2007-09-28, lerameur <lerameur@xxxxxxxxx> 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 ?
thanks
You forgot to report the errors, or a good summary of the errors, in
your post.
Ken
Did you 'use strict;', 'use warnings;'?
for my $hours ('00'..'23') {
$file23 = glob("$timestamp2$hours*") ;
Odd var name.
print "$timestamp2: " ,$timestamp2, "\n";
print "file23: " ,$file23, "\n";
if ($file23 == 1){
Why are you testing whether $file23 equals 1? You probably want:
if ($file23){
system(`cp /input/fttr/traffic/$file23 /input/$Out_directory `);
}
$hours++;
}
--
.
- References:
- looping questions
- From: lerameur
- looping questions
- Prev by Date: Re: creating something M$ Excel can read?
- Next by Date: Re: Sort and remove duplicates
- Previous by thread: looping questions
- Next by thread: Re: looping questions
- Index(es):
Relevant Pages
|
|