line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Job::Async::Utils; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
54080
|
use strict; |
|
2
|
|
|
|
|
13
|
|
|
2
|
|
|
|
|
47
|
|
4
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
94
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.004'; # 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
|
|
771
|
use Math::Random::Secure; |
|
2
|
|
|
|
|
262769
|
|
|
2
|
|
|
|
|
255
|
|
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
|
313
|
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
|
|
|
|
|
59600
|
substr $v, 13, 0, '-'; |
40
|
100
|
|
|
|
|
149
|
substr $v, 23, 0, '-'; |
41
|
100
|
|
|
|
|
197
|
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
|
|
|
|
|
|
|
|