Bill,
When I use your approach, I am getting an error:
25/02/2001-Use of uninitialized value in sprintf at ./exploitD.pl line
208.
17:14:33.016000 time="" action="" orig="bedm-edn-650-pri"
i/f_dir="inbound" i/f_
Line 208 and few lines around it are as below:
sub genOne {
my $index = shift;
my %data;
$data{'name'} = "test";
my $num = int(rand() * 100);
my $year = 1997 + intRand(5);
my $mon = intRand(12);
my $day = intRand(28) + 1;
my $date = "";
$date .= "0" if (int($day) < 10);
$date .= $day;
$date .= "\/$months[$mon]\/$year-";
print "$date";
$data{'LogFileID'} = '1044611703';
$data{'LogRecNum'} = $recNum++;
##$data{'time'} = "$date";
##-------------------
my $epochseconds = "0";
my $microseconds = "0";
($epochseconds, $microseconds) = gettimeofday;
($second, $minute, $hour) = localtime($epochseconds);
print sprintf("%02d:%02d:%02d.%06d %s", ## ----- THIS IS Line 208
$hour, $minute, $second, $microseconds);
##----------------------
Thanks,
-Kamal.
-----Original Message-----
From: Bill Curnow [mailto:[EMAIL PROTECTED]
Sent: Monday, October 04, 2004 10:48 AM
To: Kamal Ahmed; [EMAIL PROTECTED]
Subject: Re: Time in perl
On 4 Oct 2004 at 10:34, Kamal Ahmed wrote:
> I am trying to print time in a format HH:MM:SS.nnnnnn
> E.g. 08:06:26.464649
>
> Any ideas how I can do it ?
use Time::HiRes qw(gettimeofday);
($epochseconds, $microseconds) = gettimeofday;
($second, $minute, $hour) = localtime($epochseconds);
print sprintf("%02d:%02d:%02d.%06d %s",
$hour, $minute, $second, $microseconds);
One caveat, Win32 systems do not appear to be able to give you
anything smaller than milliseconds (the first three decimal places).
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs