Created
April 27, 2011 14:55
-
-
Save dolmen/944389 to your computer and use it in GitHub Desktop.
A simple wrapper for Pod::POM::Web for a shorter command-line interface
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
package PodPOMWeb; | |
use Pod::POM::Web; | |
sub import | |
{ | |
my @caller = caller; | |
if ("$caller[0]/$caller[1]" eq 'main/-e') { | |
eval q~ # Lazy parsing: only if running if -e | |
no strict 'refs'; | |
*{'main::server'} = sub { | |
if (!@_ && @ARGV) { | |
# Convert @ARGV to Pod::POM::Web->server arguments | |
# Signature: $port, \%options | |
my ($port, %args) = @ARGV; | |
%args = map { my $a = $_; s/^--//; ($_, $args{$a}) } keys %args; | |
@_ = ($port, \%args); | |
} | |
Pod::POM::Web->server(@_); | |
}; | |
~; | |
} | |
} | |
1; | |
__END__ | |
=head1 NAME | |
PodPOMWeb - Wrapper for Pod::POM::Web | |
=head1 SYNOPSIS | |
# Pod::POM::Web with default options | |
perl -MPodPOMWeb -e server | |
# Pod::POM::Web on port 8081 | |
perl -MPodPOMWeb -e server 8081 | |
=head1 DESCRIPTION | |
A simple wrapper for L<Pod::POM::Web> for a shorter command-line interface. | |
See L<http://rt.cpan.org/Public/Bug/Display.html?id=67588>. | |
=cut |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment