line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Job::Async::Utils; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
52785
|
use strict; |
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
45
|
|
4
|
2
|
|
|
2
|
|
7
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
64
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.002'; # VERSION |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Job::Async::Utils - helper functions for L |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 DESCRIPTION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Provides a few functions used in other modules. |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=cut |
17
|
|
|
|
|
|
|
|
18
|
2
|
|
|
2
|
|
816
|
use Math::Random::Secure; |
|
2
|
|
|
|
|
263856
|
|
|
2
|
|
|
|
|
282
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head2 uuid |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Generates a random (v4) UUID, returning it as a string. |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
e.g. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
$ perl -le'use Job::Async::Utils; print Job::Async::Utils::uuid()' |
27
|
|
|
|
|
|
|
5d2a5619-fb7b-44e5-048e-76adc9660c0a |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=cut |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub uuid { |
32
|
|
|
|
|
|
|
# UUIDv4 (random) |
33
|
100
|
|
|
100
|
1
|
338
|
my $v = sprintf('%08x-%08x-%08x%08x', |
34
|
|
|
|
|
|
|
Math::Random::Secure::irand(2**32), |
35
|
|
|
|
|
|
|
(Math::Random::Secure::irand(2**32) & 0xFFFF0FFF) | 0x4000, |
36
|
|
|
|
|
|
|
Math::Random::Secure::irand(2**32) & 0xBFFFFFFF, |
37
|
|
|
|
|
|
|
Math::Random::Secure::irand(2**32) |
38
|
|
|
|
|
|
|
); |
39
|
100
|
|
|
|
|
61465
|
substr $v, 13, 0, '-'; |
40
|
100
|
|
|
|
|
166
|
substr $v, 23, 0, '-'; |
41
|
100
|
|
|
|
|
216
|
return $v; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 AUTHOR |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Tom Molesworth C<< >> |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 LICENSE |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Copyright Tom Molesworth 2017. Licensed under the same terms as Perl itself. |
53
|
|
|
|
|
|
|
|