[Bps-public-commit] App-moduleswhere branch, master, updated. ba896094090c48c9315660e1f0e86ce8067cf5da
? sunnavy
sunnavy at bestpractical.com
Sun May 8 13:08:55 EDT 2011
The branch, master has been updated
via ba896094090c48c9315660e1f0e86ce8067cf5da (commit)
via 7abd3121b41c36eff9eb618a02067c158c667fe4 (commit)
from 877a15001d427645eb785eba002a47d8151dbfbe (commit)
Summary of changes:
Changes | 4 ++++
bin/mwhere | 37 +++++++++++++++++++++++++++++--------
dist.ini | 2 +-
lib/App/moduleswhere.pm | 11 ++++++-----
4 files changed, 40 insertions(+), 14 deletions(-)
- Log -----------------------------------------------------------------
commit 7abd3121b41c36eff9eb618a02067c158c667fe4
Author: sunnavy <sunnavy at bestpractical.com>
Date: Mon May 9 01:06:58 2011 +0800
--no-require option in case people do *not* like to require
diff --git a/Changes b/Changes
index 055f49d..4439944 100644
--- a/Changes
+++ b/Changes
@@ -2,6 +2,8 @@ Revision history for App-moduleswhere
{{$NEXT}}
+ add --no-require option.
+
0.02 2011-04-28 18:21:51 CST
note about Module::Info.
diff --git a/bin/mwhere b/bin/mwhere
index a0f5efe..027bce5 100755
--- a/bin/mwhere
+++ b/bin/mwhere
@@ -3,8 +3,9 @@ use strict;
use warnings;
use Getopt::Long;
+use File::Spec::Functions 'catfile';
my %args;
-GetOptions( \%args, 'help|h' ) or exit;
+GetOptions( \%args, 'no-require|n', 'help|h' ) or exit;
@ARGV = grep { defined } @ARGV;
@@ -12,18 +13,38 @@ if ( $args{help} || !@ARGV ) {
print <<'EOF';
USAGE: mwhere Module [ ... ]
EXAMPLES:
- mwhere Carp # show location of Carp.pm
- mwhere Carp CGI # copy both Carp.pm and CGI.pm
+ mwhere Carp # show location of Carp.pm
+ mwhere --no-require Carp # ditto, but no "require"
+ mwhere -n Carp # ditto
+ mwhere Carp CGI # show both Carp.pm and CGI.pm
EOF
exit;
}
for my $mod (@ARGV) {
- eval "require $mod" or warn "failed to require '$mod': $@" and next;
-
my @parts = split /::/, $mod;
- my $inc = join( '/', @parts ) . '.pm';
- my $source = $INC{$inc};
- print $source, "\n";
+ my $source;
+
+ if ( $args{'no-require'} ) {
+ $parts[-1] .= '.pm';
+ for my $inc ( @INC ) {
+ my $file = catfile( $inc, @parts );
+ if ( -e $file ) {
+ $source = $file;
+ last;
+ }
+ }
+
+ unless ( $source ) {
+ warn "failed to find $mod\n";
+ next;
+ }
+ }
+ else {
+ eval "require $mod" or warn "failed to require '$mod': $@" and next;
+ my $inc = join( '/', @parts ) . '.pm';
+ $source = $INC{$inc};
+ }
+ print "$source\n";
}
diff --git a/lib/App/moduleswhere.pm b/lib/App/moduleswhere.pm
index a2953e9..9b1b6d7 100644
--- a/lib/App/moduleswhere.pm
+++ b/lib/App/moduleswhere.pm
@@ -2,7 +2,7 @@ package App::moduleswhere;
use warnings;
use strict;
-our $VERSION = '0.02';
+our $VERSION = '0.03';
1;
@@ -14,8 +14,10 @@ App::moduleswhere - show modules' locations
=head1 SYNOPSIS
- mwhere Carp # show location of Carp.pm
- mwhere Carp CGI # copy both Carp.pm and CGI.pm
+ mwhere Carp # show location of Carp.pm
+ mwhere --no-require Carp # ditto, but no "require"
+ mwhere -n Carp # ditto
+ mwhere Carp CGI # show both Carp.pm and CGI.pm
=head1 DESCRIPTION
@@ -25,8 +27,7 @@ You may ask, why not using `perldoc -l`? well, if the module doesn't
have any pod( this happens occasionally but does happen ), `perldoc -l` will
fail, in this case, mwhere comes to rescue!
-Technically, C<mwhere> just "require" the modules first and then find the
-info in %INC, check out C<Module::Info> if you don't like the "require" way.
+check out C<Module::Info> if you want to know more info of modules.
=head1 BUGS AND LIMITATIONS
commit ba896094090c48c9315660e1f0e86ce8067cf5da
Author: sunnavy <sunnavy at bestpractical.com>
Date: Mon May 9 01:08:49 2011 +0800
release 0.03
diff --git a/Changes b/Changes
index 4439944..dd3a8ee 100644
--- a/Changes
+++ b/Changes
@@ -2,6 +2,8 @@ Revision history for App-moduleswhere
{{$NEXT}}
+0.03 2011-05-09 01:07:36 CST
+
add --no-require option.
0.02 2011-04-28 18:21:51 CST
diff --git a/dist.ini b/dist.ini
index a05757a..29831e6 100644
--- a/dist.ini
+++ b/dist.ini
@@ -1,5 +1,5 @@
name = App-moduleswhere
-version = 0.02
+version = 0.03
author = sunnavy <sunnavy at bestpractical.com>
license = Perl_5
copyright_holder = Best Practical Solutions
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list