diff options
Diffstat (limited to 'lib/FLAT/Regex/Util.pm')
-rw-r--r-- | lib/FLAT/Regex/Util.pm | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/FLAT/Regex/Util.pm b/lib/FLAT/Regex/Util.pm new file mode 100644 index 0000000..516ad9f --- /dev/null +++ b/lib/FLAT/Regex/Util.pm @@ -0,0 +1,33 @@ +package FLAT::Regex::Util; +use base 'FLAT::Regex'; + +use strict; +use Carp; + +sub get_symbol { + my @symbols = qw/0 1/; + return $symbols[rand(2)]; +} + +sub get_op { + my @ops = ('*','+','&','','','','','','',''); + return $ops[rand(10)]; +} + +sub get_random { + my $length = shift; + my $string = ''; + if (1 < $length) { + $string = get_symbol().get_op().get_random(--$length); + } else { + $string = get_symbol(); + } + return $string; +} + +sub random_pre { + my $length = ( $_[0] ? $_[0] : 32 ); + return FLAT::Regex::WithExtraOps->new(get_random($length)); +} + +1; |