This one trick pony is ridden to the end of the road,
usefully even if not portably: from a bash prompt.
(Okay, some have too many ';' in there to be one-liners strictly speaking - but they all express a linear thought, briefly enough to be easily remembered). The idea here
isn't "golf", but UYKAKYU (Use yields knowledge as knowledge yields use)
I've climbed the learning curve this past month,
far enough that I deserve to be thwacked for bad practices if you notice any you want to point out.
mkmcconn
- Print @INC
- perl -we 'print "$_\n" for @INC;'
- Print filenames in @INC to pipe
- perl -we 'push @a, <$_/*> for @INC; print "$_\n" for @a;' | more
- Search for "PerlMonks" in filenames of @INC excluding PWD
- perl -we '/^\./ or push @a, glob "$_/*" for @INC; print "$_\n" for @a;' | grep "PerlMonks"
- Grep for the lwp cookbook, perlishly
- perl -we '/^\./ or push @a, <$_/*> for @INC; print "$_\n" for grep {/lwp.+(pod)/} @a;'
- Page through all ".pm" files related to "(F|f)ile.." in @INC outside PWD, bash-fully
- less $(perl -we '/^\./ or push @a, <$_/*> for @INC; print "$_\n" for grep{/\bFile.*\.pm/i} @a;')
- Make a two-line (code-once-use-again) bash-ful aliased regexified search of leaves-only for "perl.."-stuff in @INC outside of $PWD
- % function grep4inc { perl -we '/^\./ or push @a, <$_/*> for @INC; print "$_\n" for grep {/$ARGV[0]/i} @a;' $1;}
- % grep4inc "\Wperl.[^\/]+$";
- % grep4inc "\Wperl.[^\/]+$";
- Modify all the above to use the -l switch (thanks chipmunk).
- Or do any of the above eliminating the need of @a.
- perl -wle 'for (@INC){ for (glob "$_/*"){ !/^\./ and print if /$ARGV[0]/;} }' "Stor"
- for I in $(perl -wle'for (@INC){ for (glob "$_/*"){ next if /^\./; print if /$ARGV[0]/i;}}' "lwp") ; do perldoc $I; done
- Comment on one-liner peeks at @INC
- Select or Download Code
- Watch for: Direct replies / Any replies
Replies are listed 'Best First'. | |
---|---|
Re: one-liner peeks at @INC
by chipmunk (Parson) on Feb 01, 2001 at 20:32 UTC |
Back to
Cool Uses for Perl