Skip to content

Commit

Permalink
CAVEATS and SEE ALSO
Browse files Browse the repository at this point in the history
  • Loading branch information
garu committed Mar 27, 2013
1 parent 56ea229 commit 574fd2e
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion lib/Sub/Frequency.pm
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ our @EXPORT = qw(


our @EXPORT_OK = @EXPORT; our @EXPORT_OK = @EXPORT;


our $VERSION = '0.04'; our $VERSION = '0.05';


my %probabilities = ( my %probabilities = (
'Sub::Frequency::Always' => 1.00, 'Sub::Frequency::Always' => 1.00,
Expand Down Expand Up @@ -251,6 +251,32 @@ or a percentage. Like:
In the code above, you should replace 'monkey' with a number In the code above, you should replace 'monkey' with a number
between 0 and 1, or a percentage string (such as '15%'). between 0 and 1, or a percentage string (such as '15%').
=head1 CAVEATS
* calling C<return()> will return from the block itself, not from the
parent C<sub>. For example, the code below will likely B<NOT> do what
you want:
sub foo {
sometimes { return 1 }; # WRONG! Don't do this
return 2;
}
To get the desired behavior, you can either play with modules such as
L<Scope::Upper> or do something like this:
sub foo {
my $value = 2;
sometimes { $value = 1 };
return $value;
}
=head1 SEE ALSO
L<Sub::Rate>
L<Sub::Retry>
=head1 AUTHORS =head1 AUTHORS
Expand Down

0 comments on commit 574fd2e

Please sign in to comment.