Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
EDIT: This code is wrong, see OP for correct version! Sorry...

I'm kinda feeling this would be better in the Obfuscated Code section. :-/

I feel you. It was a struggle. Is there an easier way to list CPAN EXE_FILES? I know they could be easily grepped but I want formatting and proper sorting. Feel free to golf my code. I'm sure it could be even harder to understand, I mean more efficient and/or idiomatic. I just install these as scripts in a folder in my path for easy access.

List EXE_FILES installed by CPAN:

perl -le' chomp(@_=`perldoc -T perllocal`); # List EXE_FILES installed by CPAN $_=join"\n",@_; @_=split/\"Module\"\s/; @_=grep/EXE_FILES:\s[^"]+/,@_; for(@_){ @x=split/\n/; @x=grep/EXE|0m/,@x; push@z,@x } s/^\s+\*\s+\"([^\"]+).?/$1/ for@z; @_=grep/EXE_FILES/,@z; @_=map{substr($_,11,length($_))}@_; undef@z; for(@_){ if(/\s/){ @x=split/\s/; push@z,$_ for@x } else{ push@z,$_ } } %_=map{s/^\S+\///;$_=>1}@z; print$_ for sort{lc($a)cmp lc($b)}keys%_'


List EXE_FILES installed by CPAN, by module:

perl -le' chomp(@_=`perldoc -T perllocal`); # List EXE_FILES installed by CPAN, by module $_=join"\n",@_; @_=split/\"Module\"\s/,$_; @_=grep/EXE_FILES:\s[^"]+/,@_; for(@_){ @x=split/\n/; @x=grep/EXE_FILES|0m/,@x; push@z,@x } my$m; s/^\s+\*\s+\"([^\"]+).?/$1/ for@z; for(@z){ if(/EXE_FILES:\s(.*)/){ $_{$m}=$1 # wtf }else{ $m=$_;$_{$m}=1 # aha } } for(sort{lc($a)cmp lc($b)}keys%_){ if($_{$_}=~/\s/){ @x=split/\s/,$_{$_}; s/^\S+\/// for@x; $_{$_}=join"\n ",@x }else{ $_{$_}=~s/^\S+\///g } print"$_\n $_{$_}\n" }'


STOP REINVENTING WHEELS, START BUILDING SPACE ROCKETS!CPAN 🐪

In reply to Re^2: List EXE_FILES installed by CPAN by usemodperl
in thread List EXE_FILES installed by CPAN by usemodperl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2023-01-27 02:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?