| 1 | package Patch::rand::Secure; | ||
| 2 | |||
| 3 | 1 | our $DATE = '2018-01-02'; # DATE | |
| 4 | 1 | our $VERSION = '0.001'; # VERSION | |
| 5 | |||
| 6 | 1 | ▶ | use strict 'subs', 'vars'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 1 | ▶ | use Math::Random::Secure; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | 0 | ▶ | sub import { |
|
Subroutine
import: not called CC=1 SCAR=6.9
| |||
| 11 | 0 | my $pkg = shift; | |
| 12 | |||
| 13 | 0 | my $caller = caller(); | |
| 14 | 0 | *{"$caller\::rand"} = \&Math::Random::Secure::rand; | |
| 15 | } | ||
| 16 | |||
| 17 | 0 | ▶ | sub unimport { |
|
Subroutine
unimport: not called CC=1 SCAR=6.9
| |||
| 18 | 0 | my $pkg = shift; | |
| 19 | |||
| 20 | 0 | my $caller = caller(); | |
| 21 | # XXX find a better way to restore original rand | ||
| 22 | 0 | ▶ | *{"$caller\::rand"} = sub { |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 23 | 0 | CORE::rand(@_); | |
| 24 | 0 | }; | |
| 25 | } | ||
| 26 | |||
| 27 | 1 | 1; | |
| 28 | # ABSTRACT: Replace rand() with Math::Random::Secure's version | ||
| 29 | |||
| 30 | __END__ | ||