Re: implicit numeric conversion isn't
by dave_the_m (Monsignor) on Nov 25, 2006 at 00:13 UTC
|
Perhaps the variable doesn't contain exactly what you think it does (eg invisible control characters). Or perhaps it's some wierd object with an overloaded numification operator. Try adding this on the line before to see exactly what it is:
use Devel::Peek;
Dump $step;
my $mid = $lupdate % $step ;
Dave. | [reply] [d/l] |
|
|
Thanx for the tip. The following code
my $hash = RRDs::info( $datafile );
my $hStep = $hash->{'step'};
Dump $hStep;
$hStep='301';
Dump $hStep;
PV shows what I want in each case, but the two have different FLAGS. Any of them make any sense to you.
generates:
SV = PVIV(0x8b82158) at 0x832c55c
REFCNT = 1
FLAGS = (PADBUSY,PADMY,IOK,POK,pIOK,pPOK)
IV = 300
PV = 0x8c2ee40 "300"\0
CUR = 3
LEN = 4
SV = PVIV(0x8b82158) at 0x832c55c
REFCNT = 1
FLAGS = (PADBUSY,PADMY,POK,pPOK)
IV = 300
PV = 0x8c2ee40 "301"\0
CUR = 3
LEN = 4
| [reply] |
|
|
Neither of those variables that Dump() has displayed would cause the error you see. It would be fine to use either of those 2 with the modulus operator.
Somehow, your program is seeing some other value that equates to (or is) zero. (Are warnings enabled ?)
What's happening between my $step = $hash->{'step'}; and my $mid = $lupdate % $step ; in your code ?
Cheers, Rob
| [reply] [d/l] [select] |
|
|
|
|
The first dump shows that the value of $hStep was set to the string "300" and converted to numeric (or vice versa.) My copy of RRDtool doesn't do that; only IOK is set and not POK. I'm using version 1.2.12 of RRDtool, the current is 1.2.15. You might want to check that you have a reasonably recent version of RRDtool, but as others have pointed out, that certainly isn't a direct cause of your zero modulus error.
| [reply] |
Re: implicit numeric conversion isn't
by quester (Vicar) on Nov 25, 2006 at 00:13 UTC
|
It shouldn't be taint; taint is checked for system calls, but not for simple operations like modulus.
It does work okay here (RHEL 3, perl 5.8.0).
When I run it as follows:
use strict;
use warnings;
use RRDs;
my $datafile = "temp.rrd";
my $lupdate = 12345;
my $hash = RRDs::info($datafile);
my $step = $hash->{'step'};
my $mid = $lupdate % $step;
print $mid;
... it prints 45 as expected.
Possibly the error is elsewhere in your code...? | [reply] [d/l] |
|
|
| [reply] |
|
|
That works here, too. It prints (at the moment) 187. Devel::Peek shows both $hStep and $lupdate are integers (IOK set):
SV = IV(0x9f83208) at 0x9ee8b6c
REFCNT = 1
FLAGS = (PADBUSY,PADMY,IOK,pIOK)
IV = 300
SV = IV(0x9f8320c) at 0x9ee8b78
REFCNT = 1
FLAGS = (PADBUSY,PADMY,IOK,pIOK)
IV = 1163531587
| [reply] |
|
|
Re: implicit numeric conversion isn't
by Joost (Canon) on Nov 25, 2006 at 00:13 UTC
|
perl -e'my $step = "300"; print 10 % $step'
10
| [reply] [d/l] [select] |
|
|
| [reply] |
|
|
| [reply] |
Re: implicit numeric conversion isn't
by Anonymous Monk on Nov 25, 2006 at 08:11 UTC
|
Well, another embarrassing bug solved. I was looping through a bunch of structures and, wouldn't you know it, one of the structures at the end didn't have stuff in it, which caused the zero size. Based upon what my testing web page was telling me, I thought the problem was at the beginning rather than the end. Thanx for your suggestions, I learned a few more things today. | [reply] |
|
|
| [reply] |