| 1 |
#! /usr/local/bin/perl -w |
| 2 |
# |
| 3 |
# roman - generate a regular expression that matches the roman numerals |
| 4 |
# from 1 to 20. |
| 5 |
# |
| 6 |
# you can over-ride the upper bound (20) by specifying the value |
| 7 |
# on the command line. You can also specify an indent value to |
| 8 |
# pretty-print the resulting regexp. |
| 9 |
# |
| 10 |
# Copyright (C) David Landgren 2005 |
| 11 |
|
| 12 |
use strict; |
| 13 |
use Regexp::Assemble; |
| 14 |
|
| 15 |
my $max = shift || 20; |
| 16 |
my $indent = shift || 0; |
| 17 |
|
| 18 |
eval "use Math::Roman 'roman'"; |
| 19 |
$@ and die "You must install Math::Roman to run this example\n"; |
| 20 |
|
| 21 |
my $r = Regexp::Assemble->new; |
| 22 |
$r->add(roman($_)) for 1..$max; |
| 23 |
|
| 24 |
print $r->as_string( indent => $indent ), "\n"; |