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":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.