http://qs321.pair.com?node_id=1217311


in reply to Re: List EXE_FILES installed by CPAN
in thread List EXE_FILES installed by CPAN

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 🐪