Variables tied to this class specify a boot-time in seconds since the epoch. When read back later, the variable returns the number of timeticks since boot. A timetick is 0.01s. The result is returned to a precision of 100 timeticks (1s).
use Net::Raddle::TicksSince; use Date::Calc qw(Mktime);
my $SinceBoot; tie $SinceBoot, "Net::Raddle::TicksSince", Mktime( 2002, 9, 24, 3, 59, 14) or die "cannot tie the knot"; print "It is now $SinceBoot ticks since boot-time\n";
TicksSince will throw an exception using die if the boot-time is not passed as an integer.
When used with Net::Raddle::SNMPAgent it is not necessary to include the 'use' line. Statements llike this will work:
$agent->TieMIBItem( CanonicalOID('SNMPv2-MIB::sysUpTime.0'), ASN_TIMETICKS, "Net::Raddle::TicksSince", Mktime( 2003, 1, 11, 8, 59, 14) );
Any request for sysUpTime.0 will now return the time since 08:59:14 on 11th January 2003, in unites of 0.01s. As this is a 32-bit quantity, it wraps around after 497 days and a few hours.