use strict;
use warnings;
use Test::More tests=>3;
my @required = (
qq(
)
.qq(2.1. Match Literal Text
\n),
qq()
.qq(2.2. Match Nonprintable Characters
\n),
qq()
.qq(2.3. Match One of Many Characters
\n),
);
my @ol_file_array = (
"2.1. Match Literal Text
\n",
"2.2. Match Nonprintable Characters
\n",
"2.3. Match One of Many Characters
\n",
);
my $regex = qr/
(?(<\w\d))
(?>)
(?(\d\.(\d+?)\.))\s
(?(.+))
(?(\b<\/\w\d>))
/xms;
foreach (@ol_file_array) {
if ($_ =~ m/$regex/g) {
substr($_, 3, 0) = changer( $+{text} );
ok( $_ eq shift(@required), $_ );
}
else {
... # blah blah blah
}
}
sub changer{
(my $id = $_[0]) =~ tr /A-Z /a-z_/;
return qq/ id="$id"/;
}
####
C:\Users\Bill\forums\monks> tony3.pl
1..3
ok 1 - 2.1. Match Literal Text
#
ok 2 - 2.2. Match Nonprintable Characters
#
ok 3 - 2.3. Match One of Many Characters
#