line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Pipe::RandomCase; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
61725
|
use strict; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
133
|
|
4
|
3
|
|
|
3
|
|
18
|
use warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
115
|
|
5
|
3
|
|
|
3
|
|
982
|
use parent 'Text::Pipe::Base'; |
|
3
|
|
|
|
|
380
|
|
|
3
|
|
|
|
|
31
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
__PACKAGE__->mk_scalar_accessors(qw(probability)); |
10
|
|
|
|
|
|
|
__PACKAGE__->mk_boolean_accessors(qw(force_one)); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub filter_single { |
13
|
1
|
|
|
1
|
1
|
17982
|
my ( $self, $input ) = @_; |
14
|
1
|
|
50
|
|
|
6
|
my $prob = $self->probability || 4; |
15
|
1
|
50
|
|
|
|
18
|
$input =~ s/(.)/int rand $prob ? $1 : uc $1 /ge; |
|
6
|
|
|
|
|
96
|
|
16
|
1
|
50
|
33
|
|
|
6
|
if ( $self->force_one and $input !~ /[[:upper:]]/ ) { |
17
|
0
|
|
|
|
|
0
|
my $pos = int( rand( length -1 ) ); |
18
|
0
|
|
|
|
|
0
|
substr( $input, $pos, 1, uc( substr( $input, $pos, 1 ) ) ); |
19
|
|
|
|
|
|
|
} |
20
|
1
|
|
|
|
|
22
|
return $input; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
1; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
__END__ |