Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
<UPDATE> prompted by a reaction in the chatterbox

If you get upset by things like seeing the company name "Microsoft" rendered in various creative / implicitly critical ways, please stop reading now; I don't want to inadvertantly help you even to a tiny degree with this code! Making even one of your days a tiny bit easier might distract you from the important recognition that you've got far worse problems than doskey macros to deal with (problems of an cognitive sort), and it would thus be uncompassionate of me. Shoo.

</UPDATE>

I was just looking at how impoverished* my Windo$e CMD.exe prompt seemed (I go months without using one, but building Perl under Win32(native) a little while ago made me get re-acquainted with it). I decided to pull together a few doskey macros that could be loaded into a CMD session at any point (by running a batch *.cmd file). Here they are.

* compared with my Cygwin shell

@ECHO OFF rem ark * We have to get perl into our path so this tries to make sur +e rem * that it will be. Tested *only* on Windows XP. Most users mi +ght rem * just as well remove this if they are sure Perl is always in + PATH. @PATH | findstr /R /I /O "perl[^\\]*\\bin" >NUL @if ERRORLEVEL 1 ( REM EMBER TO adjust this for the path to perl.EXE on your system. set PATH=c:\ADDITI~1\win32perl\bin;%PATH% ) rem desc * a better dir command that outputs what we expect such a com +mand rem * to do, w/o the leading and trailing junk. doskey udir=perl -le "$ad=pop(@ARGV);$ad=q[.] unless $ad;@zult=(grep{$ +_ and not /\A\s/}grep[chomp],`cmd /c dir $ad /N/Q/TW`);for((grep subs +tr($_,24,5) eq q[<DIR>],@zult),(grep substr($_,24,5) ne q[<DIR>],@zul +t)){s{\s\s[[:upper:]]+\\}{};print}" $* doskey uloc=perl -MFile::Find=find -MEnv=@PATH -wle "$ARGV[0]=qw[ $* ] +;die q[An argument is required! Aborting.] unless $ARGV[0];print qq/L +ooking for $ARGV[0]/;@lf=$ARGV[0];push @lf,qq|$ARGV[0].exe| unless $A +RGV[0]=~/\.exe$/i; find(sub{$ef=$_;return unless grep{$ef eq $_ or /\ +A\Q$ef\E\z/i}@lf;$ff=$File::Find::name;$ff=~y:/:\\:;print $ff and exi +t 0},@PATH); print q[None found.]" doskey pmquery=perl -le "do{$modn=$_;s!::!/!g;$_.=q[.pm];print qq[$mod +n is not installed.\n] and next if !(eval{require \"$_\";1} and !$@); +$modv=defined(${$modn.q[::VERSION]}) ?${$modn.q[::VERSION]}:q{[versio +n undefined]};$numtyp=(2>$modv=~tr/.//) ?'%%s':'%% 6d';printf qq[ %% +-*s $numtyp in %%s\n],(length>30 ? 5+length:15+length),$modn,$modv,$I +NC{$_}}for @ARGV;" $* doskey perlv=perl -le "printf qq[%%vd$/]=> $^V" doskey checkpath=perl -MEnv=@PATH -le "print for map {-d $_ ? lcfirst( +$_):qq[$_ ** DOES NOT EXIST **]}@PATH" doskey checkperlinc=perl -le "print for map {-d $_ ? lcfirst($_):qq[$_ + ** DOES NOT EXIST **]}@INC" doskey checktempdirs=perl -e "print for map {sprintf(q[%%-6s is %%s].q +q[\n], $_, ($ENV{$_} || 'not defined in env'))}qw(TEMP TMP TMPDIR)"

  • pmquery tells us the location and (if applicable) version of an installed Perl module. Quite useful.
  • perlv simply prints the familiar (new 'v-string' style) Perl version.
  • checkpath pretty-prints the elements in PATH, one per line.
  • checkperlinc pretty-prints the elements in Perl's @INC, one per line.
  • checktempdirs shows what each of the commonly looked-at temporary file locations is defined to, or shows if it is not.
  • uloc and udir are my experiments with reimplementing the `which' and `dir' commands. uloc in particular is not truly reliable.

Note that as Windo$e CMD shell has no concept of "continuing a single command over multiple lines by escaping the line-endings (with "\"), these doskey definitions must be single lines, no matter how they end up looking on your screen (in a browser or editor). Cleaning them up is the reader's responsibility.


In reply to Re: Private Utilities by Intrepid
in thread Private Utilities by Ovid

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?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2024-04-16 06:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found