summaryrefslogtreecommitdiff
path: root/lib/FLAT/Regex/Util.pm
blob: 516ad9f0cd5ff45f274f2725e2af7f84ab601f2e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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;