PracticeDev/study_perl/test_upid.pl

13 lines
453 B
Perl
Raw Normal View History

2022-12-20 17:31:11 +08:00
sub upid_encode {
my $d = shift;
# Note: pstart can be > 32bit if uptime > 497 days, so this can result in
# more that 8 characters for pstart
return sprintf("UPID:%s:%08X:%08X:%08X:%s:%s:%s:", $d->{node}, $d->{pid},
$d->{pstart}, $d->{starttime}, $d->{type}, $d->{id},
$d->{user});
}
print upid_encode({
node => 'pve', pid => 3333, pstart => 34234,
starttime => 34234324, type => 'unknow', id => '', user => 'root@pve' });