PP.pm

filter: Statementstmt 33.3% 1 / 3 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 1 / 1 Podpod n/a totaltotal 50.0% 2 / 4 CC 1 SCAR 2.6
CC
1
Cov
33%
BEGIN
1.3
CRAP 1.3
« PP/OO.pm ↑ Summary
1 package Scalar::Random::PP;
2 0 ▶use Scalar::Random::PP::OO;
Subroutine BEGIN: called CC=1 SCAR=2.6
3 use 5.008003;
4  
5 our $VERSION = '0.11';
6  
7 has 'limit' => ( is => 'ro' );
8  
9 Scalar::Random::PP::OO::Exporter->setup_import_methods(
10 as_is => [\&randomize],
11 );
12  
13 use overload
14 '""' => sub { int(rand($_[0]->limit + 1)) },
15 fallback => 1;
16  
17 sub randomize {
18 $_[0] = Scalar::Random::PP->new(limit => $_[1]);
19 }
20  
21 1;
22  
23 =encoding utf8
24  
25 =head1 NAME
26  
27 Scalar::Random::PP - Scalar::Random in Pure Perl
28  
29 =head1 SYNOPSIS
30  
31 use Scalar::Random::PP 'randomize';
32  
33 my $random;
34 my $MAX_RANDOM = 100;
35  
36 randomize( $random, $MAX_RANDOM );
37  
38 print $random, "\n"; # '42'
39 print $random, "\n"; # '17'
40 print $random, "\n"; # '88'
41 print $random, "\n"; # '4'
42 print $random, "\n"; # '50'
43  
44 =head1 DESCRIPTION
45  
46 This module is intended to be a pure Perl replacement for L<Scalar::Random>.
47  
48 Please see L<Scalar::Random> for full details.
49  
50 =head1 NOTES
51  
52 This module was written as a pair programming excerise between
53 Webster Montego and Ingy döt Net.
54  
55 The module passes all the same tests as L<Scalar::Random>, even though
56 we felt there could be more exhaustive testing. Perhaps we'll add the
57 tests we'd like to see, so that Alfie John can backport them. :)
58  
59 We also thought it would be nice if randomize took a lower limit, but we
60 decided not to change the API unless Alfie did so first, so that the PP
61 module would be an exact replacement.
62  
63 We used the speedy and zero-dep L<Mousse> module for OO goodness, and
64 packaged it all up with the lovely L<Module::Install> and friends.
65  
66 =head1 RESOURCES
67  
68 GitHub: L<http://github.com/websteris/scalar-random-pp-pm>
69  
70 =head1 AUTHORS
71  
72 Webster Montego <websteris@cpan.org>
73  
74 Ingy döt Net <ingy@cpan.org>
75  
76 =head1 COPYRIGHT
77  
78 Copyright (c) 2010. Webster Montego and Ingy döt Net
79  
80 This program is free software; you can redistribute it and/or modify it
81 under the same terms as Perl itself.
82  
83 See L<http://www.perl.com/perl/misc/Artistic.html>
84  
85 =cut
« PP/OO.pm ↑ Summary