[Asterisk-Users] Strange variable chopping from AGI's

Steven Critchfield critch at basesys.com
Mon Dec 8 14:51:16 MST 2003


On Mon, 2003-12-08 at 15:31, John Todd wrote:
> AGI's are resulting in unusual behaviors.  Can someone please tell me 
> if this is my inappropriate use of AGI's, inappropriate use of 
> Time::HiRes, or a bug with *:
> 
> I call this script twice:
> 
> #!/usr/bin/perl
> use Time::HiRes qw( gettimeofday );
> ($seconds, $microseconds) = gettimeofday;
> $hirestime = sprintf("%s","$seconds$microseconds");
> print "SET VARIABLE HIRESTIMESTAMP $hirestime\n";

I think your problem is with the fact that leading zeros in
$microseconds are not important enough to show up. What you need to do
is dived it by 1000 to shift the digits down and preserve the leading
zeros. Then you won't get chomping of digits when you sprintf the
combination. Either that or you will need to multiply the seconds by
1000 before adding the two fields together and staying all microseconds.
-- 
Steven Critchfield  <critch at basesys.com>




More information about the asterisk-users mailing list