From: Jan T. <de...@us...> - 2002-05-09 19:13:06
|
Update of /cvsroot/net-script/netscript2/src/perl/NetScript/Util In directory usw-pr-cvs1:/tmp/cvs-serv26609 Added Files: UIDGenerator.pm Log Message: * added a generator for Unique IDs --- NEW FILE: UIDGenerator.pm --- #-------------------------------------------------------- # $Id: UIDGenerator.pm,v 1.1 2002/05/09 19:13:03 derkork Exp $ # # Class UIDGenerator # # NetScript and all related materials, such as documentation, # are protected under the terms and conditions of the Artistic License. # (C) 2000-2002 by Jan Thomä, insOMnia # mailto: ko...@in... #-------------------------------------------------------- use strict; #/** # The UIDGenerator generates unique IDs for any purpose. # The UIDGenerator uses <code>Time::HiRes</code> for generation # of IDs. The IDs are guaranteed to be unique for the same host. #*/ package NetScript::Util::UIDGenerator; use vars qw($VERSION); use Time::HiRes qw( time ); #/** # Ctor. #*/ sub new { my ($proto ) = @_; my $proto = shift; # get Prototype my $class = ref( $proto ) || $proto;# get the Classname my $this = {}; bless( $this, $class ); # create Object return $this; # return Object } #/** # Returns a scalar holding a unique ID. # @return a scalar. # @public #*/ sub createUID { my ( $this ) = @_; "$$-$^T-".time()."-".rand(); } 1; # make require happy |