App-url
view release on metacpan or search on metacpan
Makefile.PL view on Meta::CPAN
a module.
To build the distribution, run this file normally:
% perl Makefile.PL
But, it's more interesting than that. You can load it with C<require>
and call C<arguments> to get the data structure it passes to
C<WriteMakefile>:
my $package = require '/path/to/Makefile.PL';
my $arguments = $package->arguments;
Note that C<require>-ing a file makes an entry in C<%INC> for exactly
that name. If you try to C<require> another file with the same name,
even from a different path, C<require> thinks it has already loaded
the file. As such, I recommend you always require the full path to the
file.
The return value of the C<require> is a package name (in this case,
the name of the main module. Use that to call the C<arguments> method.
lib/App/url.pm view on Meta::CPAN
# $v - value that corresponds to position in template
# $V - list of all values
# $l - letter
my $formatter = String::Sprintf->formatter(
a => sub ( $w, $v, $V, $l ) { $V->[0]->path },
f => sub ( $w, $v, $V, $l ) { $V->[0]->fragment },
h => sub ( $w, $v, $V, $l ) { $V->[0]->host },
H => sub ( $w, $v, $V, $l ) { ( split /\./, $V->[0]->host )[0] },
i => sub ( $w, $v, $V, $l ) { $V->[0]->ihost },
I => sub ( $w, $v, $V, $l ) {
state $rc = require Socket;
my @addresses = gethostbyname( $V->[0]->host );
@addresses = map { Socket::inet_ntoa($_) } @addresses[4..$#addresses];
"@addresses";
},
p => sub ( $w, $v, $V, $l ) { $V->[0]->port // do {
if( $V->[0]->protocol eq 'http' ) { 80 }
elsif( $V->[0]->protocol eq 'https' ) { 443 }
};
},
P => sub ( $w, $v, $V, $l ) { $V->[0]->password },
( run in 0.364 second using v1.01-cache-2.11-cpan-0d8aa00de5b )