Discussion:
[cgi-prototype-users] please patch PathInfo with this
Terrence Brannon
2005-09-10 12:30:02 UTC
Permalink
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";
}
A. Pagaltzis
2005-09-10 15:55:57 UTC
Permalink
Post by Terrence Brannon
I am using this in my version of PathInfo.
What for?

Regards,
--
#Aristotle
*AUTOLOAD=*_=sub{s/(.*)::(.*)/print$2,(",$\/"," ")[defined wantarray]/e;$1};
&Just->another->Perl->hacker;
Terrence Brannon
2005-09-10 20:45:06 UTC
Permalink
Post by A. Pagaltzis
Post by Terrence Brannon
I am using this in my version of PathInfo.
What for?
it would be nice for you to preserve a bit more context... but anyway,
I am needing the name of the .pm file for each resource_type so that I
an execute the "view source for this page" link that is on each page.

E.g, this link:

http://www.metaperl.org/Guestbook/viewsrc/welcome

Shows the source that was used for this page:

http://www.metaperl.org/Guestbook/welcome
Terrence Brannon
2005-09-14 19:47:27 UTC
Permalink
Aristotle, any feedback on my requested patch?
Post by Terrence Brannon
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 $pkg = join '::', (
$self->config_class_prefix,
split( m{/}, $self->validate_name( $name ) ),
);
$pkg =~ s!::!/!g;
"$pkg.pm";
}
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
--
Carter's Compass: I know I'm on the right track when,
by deleting something, I'm adding functionality.
Loading...