1 |
use strict;
|
2 |
use vars qw(%PROP %SET %SET_ALIAS $VERSION);
|
3 |
$VERSION=do{my @r=(q$Revision: 1.11 $=~/\d+/g);sprintf "%d."."%02d" x $#r,@r};
|
4 |
|
5 |
$PROP{perl_namespace_name} = 'Char::Class::';
|
6 |
$PROP{module_name} = 'FooScript';
|
7 |
|
8 |
sub header () {
|
9 |
<<"EOH";
|
10 |
## This file is auto-generated (at @{[ sprintf '%04d-%02d-%02dT%02d:%02d:%02dZ', (gmtime)[5]+1900, (gmtime)[4]+1, (gmtime)[3,2,1,0] ]}).
|
11 |
## Do not edit by hand!
|
12 |
use strict;
|
13 |
|
14 |
package $PROP{perl_namespace_name}$PROP{module_name};
|
15 |
our \$VERSION = '$PROP{version}';
|
16 |
@{[
|
17 |
#package main;
|
18 |
]}
|
19 |
use Exporter;
|
20 |
use vars qw(\@EXPORT_OK \@ISA \$VERSION);
|
21 |
\@ISA = qw(Exporter);
|
22 |
|
23 |
=head1 NAME
|
24 |
|
25 |
$PROP{perl_namespace_name}$PROP{module_name} - Regular Expression Character Classes - C<@{[ length $PROP{prefix_name} ? $PROP{prefix_name} : $PROP{module_name} ]}>
|
26 |
@{[$PROP{pod_description}? "
|
27 |
=head1 DESCRIPTION
|
28 |
|
29 |
$PROP{pod_description}":'']}
|
30 |
|
31 |
=cut
|
32 |
|
33 |
sub import (\$;\@) {
|
34 |
my (\$self, \@sub) = (shift, \@_);
|
35 |
for (\@sub) {
|
36 |
no strict 'refs';
|
37 |
*{'main::'.\$_} = \\&{\$_};
|
38 |
}
|
39 |
\$Exporter::ExportLevel = 1;
|
40 |
\$self->SUPER::import (\@_);
|
41 |
\$Exporter::ExportLevel = 0;
|
42 |
}
|
43 |
|
44 |
EOH
|
45 |
}
|
46 |
|
47 |
sub table () {
|
48 |
my $prefix = exists $PROP{prefix_name} ? $PROP{prefix_name} : $PROP{module_name};
|
49 |
my $r = '';
|
50 |
my @set;
|
51 |
my %set_description;
|
52 |
for (sort keys %SET) {
|
53 |
my (@aline,@aitem);
|
54 |
$SET{$_} =~ s{^#\+(\w+)$}{
|
55 |
push @aline, qq(\&In${prefix}$1.); ''
|
56 |
}mge;
|
57 |
$SET{$_} =~ s{^!(.+)$}{ ## Pre-formatted
|
58 |
push @aitem, $1; ''
|
59 |
}mge;
|
60 |
$SET{$_} =~ s{^#DESCRIPTION\x20(.+)$}{
|
61 |
$set_description{qq(In${prefix}$_)} = $1; ''
|
62 |
}me;
|
63 |
$SET{$_} =~ s{^#.+$}{}mg;
|
64 |
$SET{$_} =~ tr/\x09\x0A\x0D\x20//d;
|
65 |
push @set, [qq(In${prefix}$_) =>
|
66 |
join "\n", qq(sub In${prefix}$_ {),
|
67 |
@aline,
|
68 |
(length $SET{$_}?
|
69 |
(q(<<EOH;),
|
70 |
@aitem,
|
71 |
(map {sprintf '%04X', $_} sort {$a <=> $b}
|
72 |
map {ord $_} split //, $SET{$_}),
|
73 |
q(EOH)):
|
74 |
@aitem > 0? (q(<<EOH;), @aitem, q(EOH)): "''"),
|
75 |
q(})
|
76 |
];
|
77 |
}
|
78 |
for (sort keys %SET_ALIAS) {
|
79 |
push @set, [qq(In${prefix}$_) => qq(\*In${prefix}$_ = \\&In${prefix}$SET_ALIAS{$_};)];
|
80 |
$set_description{qq(In${prefix}$_)} = qq<An alias for In${prefix}$SET_ALIAS{$_}.>;
|
81 |
}
|
82 |
|
83 |
$r = qq(\@EXPORT_OK = qw(@{[map {$_->[0]} @set]});\n\n);
|
84 |
$r .= join '', map {$_->[1]."\n\n"} @set;
|
85 |
|
86 |
$r .= "=head1 COLLECTION NAMES\n\n=over 4\n\n";
|
87 |
for (sort {$a->[0] cmp $b->[0]} @set) {
|
88 |
$r .= sprintf "=item C<%s>\n\n", $_->[0];
|
89 |
$r .= sprintf "%s\n\n", $set_description{ $_->[0] }
|
90 |
if $set_description{ $_->[0] };
|
91 |
}
|
92 |
$r .= "=back\n\n=cut\n\n";
|
93 |
|
94 |
$r;
|
95 |
}
|
96 |
|
97 |
sub footer () {
|
98 |
my $r = <<EOH;
|
99 |
@{[$PROP{pod_example}? "
|
100 |
=head1 EXAMPLE
|
101 |
|
102 |
$PROP{pod_example}":"
|
103 |
=head1 EXAMPLE
|
104 |
|
105 |
use $PROP{perl_namespace_name}$PROP{module_name};
|
106 |
if (\$s =~ /\\p{In@{[[each %SET]->[0]]}}/) {
|
107 |
print \"Match!\\n\";
|
108 |
}
|
109 |
"]}@{[$PROP{pod_see_also}? "
|
110 |
=head1 SEE ALSO
|
111 |
|
112 |
$PROP{pod_see_also}":'']}@{[$PROP{pod_license}? "
|
113 |
=head1 LICENSE
|
114 |
|
115 |
$PROP{pod_license}":"
|
116 |
=head1 LICENSE
|
117 |
|
118 |
Copyright @{[(gmtime)[5]+1900]} $PROP{author_name} <$PROP{author_mail}>
|
119 |
|
120 |
This library and the library generated by it is free software;
|
121 |
you can redistribute them and/or modify them under the same
|
122 |
terms as Perl itself.
|
123 |
"]}
|
124 |
=cut
|
125 |
|
126 |
1;
|
127 |
### $PROP{module_name}.pm ends here
|
128 |
EOH
|
129 |
$r;
|
130 |
}
|
131 |
|
132 |
sub col2list ($) {
|
133 |
my $s = shift;
|
134 |
my @s;
|
135 |
my @c;
|
136 |
$s =~ s{^(#.+)}{
|
137 |
push @c, $1; '';
|
138 |
}gem;
|
139 |
$s =~ s{^[\x20\x09]*([0-9A-F][0-9A-F])((?:[\x20\x09]+[0-9A-F][0-9A-F](?:-[0-9A-F][0-9A-F])?)+)}{
|
140 |
my ($r, @c) = ($1, grep {length} split /\s+/, $2);
|
141 |
for (@c) {
|
142 |
if (/([0-9A-F][0-9A-F])-([0-9A-F][0-9A-F])/) {
|
143 |
push @s, sprintf '%s%s %s%s ', $r,$1, $r,$2;
|
144 |
} else {
|
145 |
push @s, sprintf '%s%s', $r,$_;
|
146 |
}
|
147 |
}
|
148 |
}gem;
|
149 |
join ("\n", @c, map {'!'.$_} @s)."\n";
|
150 |
}
|
151 |
|
152 |
sub print_module () {
|
153 |
no warnings;
|
154 |
print &header.&table.&footer;
|
155 |
}
|
156 |
|
157 |
=head1 NAME
|
158 |
|
159 |
mkpm.pl --- Char::Class::* modules generating library
|
160 |
|
161 |
=head1 LICENSE
|
162 |
|
163 |
Copyright 2002-2003 Wakaba <w@suika.fam.cx>
|
164 |
|
165 |
This library and the library generated by it is free software;
|
166 |
you can redistribute them and/or modify them under the same
|
167 |
terms as Perl itself.
|
168 |
|
169 |
=cut
|
170 |
|
171 |
1; ## $Date: 2004/06/04 08:29:56 $
|
172 |
### mkpm.pl ends here
|