Mojo::Path - Path
use Mojo::Path; my $path = Mojo::Path->new('/foo/bar%3B/baz.html'); shift @{$path->parts}; say $path;
Mojo::Path is a container for URL paths.
Mojo::Path implements the following attributes.
leading_slash
my $leading_slash = $path->leading_slash; $path = $path->leading_slash(1);
Path has a leading slash.
parts
my $parts = $path->parts; $path = $path->parts([qw/foo bar baz/]);
The path parts.
trailing_slash
my $trailing_slash = $path->trailing_slash; $path = $path->trailing_slash(1);
Path has a trailing slash.
Mojo::Path inherits all methods from Mojo::Base and implements the following new ones.
new
my $path = Mojo::Path->new; my $path = Mojo::Path->new('/foo/bar%3B/baz.html');
Construct a new Mojo::Path object.
canonicalize
$path = $path->canonicalize;
Canonicalize path.
# "/foo/baz" say Mojo::Path->new('/foo/bar/../baz')->canonicalize;
clone
my $clone = $path->clone;
Clone path.
contains
my $success = $path->contains('/foo');
Check if path contains given prefix.
# True Mojo::Path->new('/foo/bar')->contains('/'); Mojo::Path->new('/foo/bar')->contains('/foo'); Mojo::Path->new('/foo/bar')->contains('/foo/bar'); # False Mojo::Path->new('/foo/bar')->contains('/f'); Mojo::Path->new('/foo/bar')->contains('/bar'); Mojo::Path->new('/foo/bar')->contains('/whatever');
parse
$path = $path->parse('/foo/bar%3B/baz.html');
Parse path.
to_abs_string
my $string = $path->to_abs_string;
Turn path into an absolute string.
to_string
my $string = $path->to_string;
Turn path into a string.
Mojolicious, Mojolicious::Guides, http://mojolicio.us.
To install Mojolicious, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojolicious
CPAN shell
perl -MCPAN -e shell install Mojolicious
For more information on module installation, please visit the detailed CPAN module installation guide.