Terrence Brannon
2005-09-10 12:30:02 UTC
I am using this in my version of PathInfo. There could be some
refactoring to share code with name_to_page, but that's not done right
now.
=item name_to_pm
Called with a page name, translates it to a .pm file name, and returns it.
This module expects page names to look like relative URLs and will translate to
package names like you'd expect, ie assuming the default
C<config_class_prefix>, C<foo/bar> will translate to C<My/App/foo/bar.pm>.
=cut
sub name_to_pm {
my $self = shift;
my ( $name ) = @_;
my $pkg = join '::', (
$self->config_class_prefix,
split( m{/}, $self->validate_name( $name ) ),
);
$pkg =~ s!::!/!g;
"$pkg.pm";
}
refactoring to share code with name_to_page, but that's not done right
now.
=item name_to_pm
Called with a page name, translates it to a .pm file name, and returns it.
This module expects page names to look like relative URLs and will translate to
package names like you'd expect, ie assuming the default
C<config_class_prefix>, C<foo/bar> will translate to C<My/App/foo/bar.pm>.
=cut
sub name_to_pm {
my $self = shift;
my ( $name ) = @_;
my $pkg = join '::', (
$self->config_class_prefix,
split( m{/}, $self->validate_name( $name ) ),
);
$pkg =~ s!::!/!g;
"$pkg.pm";
}