Created
December 2, 2015 04:47
-
-
Save hideki-a/9cd97585fb10148b26d4 to your computer and use it in GitHub Desktop.
指定の範囲内で乱数を発生させるプラグイン
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| id: SetRandomNumVar | |
| name: Set Random Number Variable Plugin | |
| version: 1.0 | |
| author_name: Hideki Abe | |
| author_link: https://www.anothersky.pw/ | |
| tags: | |
| function: | |
| SetRandomNumVar: | |
| handler: > | |
| sub { | |
| my($ctx, $args) = @_; | |
| my $min = $args->{ range }->[0]; | |
| my $max = $args->{ range }->[1]; | |
| # http://perl.wansdream.net/article/114897420.html | |
| my $ret = int( ( rand() * ( $max - $min + 1 ) ) + $min ); | |
| $ctx->var( $args->{ name }, $ret ); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <$mt:SetRandomNumVar name="tmp.random_num" range="100","199"$> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment