Permalink
Browse files

CAVEATS and SEE ALSO

  • Loading branch information...
garu committed Mar 27, 2013
1 parent 56ea229 commit 574fd2e187f411974019536aee529aa7b2336969
Showing with 27 additions and 1 deletion.
  1. +27 −1 lib/Sub/Frequency.pm
View
@@ -15,7 +15,7 @@ our @EXPORT = qw(
our @EXPORT_OK = @EXPORT;
-our $VERSION = '0.04';
+our $VERSION = '0.05';
my %probabilities = (
'Sub::Frequency::Always' => 1.00,
@@ -251,6 +251,32 @@ or a percentage. Like:
In the code above, you should replace 'monkey' with a number
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

0 comments on commit 574fd2e

Please sign in to comment.