Re: looping questions
- From: xhoster@xxxxxxxxx
- Date: 28 Sep 2007 21:51:25 GMT
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
Ken
for my $hours ('00'..'23') {
$file23 = glob("$timestamp2$hours*") ;
You don't want to use scalar glob here. globs are kind of weird,
and it won't notice that it's argument changed until the is done iterating
through all of the files that matched its initial invocation (and has
returned undef once). Then it will look at its argument again, and start
iterating over that result. If you know that no more than one file will
match, or you only care about one of the matches in cases where there are
more than one, you could get it by using a list context:
my ($file23) = glob("$timestamp2$hours*") ;
print "$timestamp2: " ,$timestamp2, "\n";
print "file23: " ,$file23, "\n";
if ($file23 == 1){
That is wrong. It is not clear what exactly is wrong because we don't
what you want it to do.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
.
- References:
- looping questions
- From: lerameur
- looping questions
- Prev by Date: Re: looping questions
- Next by Date: Re: Read attachment
- Previous by thread: Re: looping questions
- Next by thread: Re: looping questions
- Index(es):
Relevant Pages
|