- or download this
my @strings = qw(aaabbbccc abc aaaaabbbbbccccc abbccc);
print "\nAttempt 1\n";
...
while (s/^a(a*)b(b*)c(c*)$/$1$2$3/g) {};
print ($_ ? "Rejected" : "Accepted","\n");
}
- or download this
print "\nAttempt 2\n";
my $count;
...
print "$str: ";
print ($str =~ m/$re2/ ? "Accepted" : "Rejected","\n");
}
- or download this
$rule_i = qr/ (??{$alpha_v1}) (??{$alpha_v2}) ... (??{$alpha_vn}) /x;
- or download this
$alpha_N = qr/ (??{$rule_1}) | (??{$rule_2}) | ... | (??{$rule_n}) /x
+;
- or download this
$START = $alpha_N;
- or download this
$alpha_Jim = qr/ Jim \s* /x;
$alpha_big = qr/ big \s* /x;
$alpha_green = qr/ green \s* /x;
$alpha_cheese = qr/ cheese \s* /x;
$alpha_ate = qr/ ate \s* /x;
- or download this
$rule_1 = qr/ (??{$alpha_N}) /x;
$rule_2 = qr/ (??{$alpha_A}) (??{$alpha_P})/x;
...
$rule_6 = qr/ (??{$alpha_cheese}) /x;
$rule_7 = qr/ (??{$alpha_Jim}) /x;
$rule_8 = qr/ (??{$alpha_ate}) /x;
- or download this
$alpha_P = qr/ (??{$rule_1}) | (??{$rule_2}) /x;
$alpha_S = qr/ (??{$rule_3}) /x;
$alpha_A = qr/ (??{$rule_4}) | (??{$rule_5}) /x;
$alpha_N = qr/ (??{$rule_6}) | (??{$rule_7}) /x;
$alpha_V = qr/ (??{$rule_8}) /x;
- or download this
$START = $alpha_S;
$G = qr/ ^ (??{$START}) $ /x;
- or download this
@strings = ('Jim ate cheese','big Jim ate green cheese',
'big cheese ate Jim',
...
foreach (@strings) {
print "Try: $_ -- ", /$G/ ? "Accepted" : "Rejected", "\n";
}