perl -we "print join qq'\n', split ';', $ENV{path}"
|
|---|
| Replies are listed 'Best First'. | ||||
|---|---|---|---|---|
|
RE: Windows Path
by Intrepid (Curate) on Sep 26, 2000 at 09:37 UTC | ||||
Welll (drawl) .. pretty nice, but .. how about a nice little DOSKEY macro assisted by Perl, to give you a nice UNI*-style path listing if you have HOMEDRIVE defined in your ENV, or DOS-style with proper right-leaning slashes if not? ($ENV{'HOMEDRIVE'} maps a drive to the UNI* root `/'; on my system that's `D:'). Could come in handy.
This is equivalent to the one-liner below (DOSKEY macros cause us to generate rather obfuscated Perl, don't they :-)?
On my system, to illustrate what I mean, this is output: /console /usr/local/bin/java/bin /MingW32/gcc-2.95.2/bin /bin /ActivePERL/bin /usr/bin /e/scr /c/WINNT/system32 /c/WINNT /c/stdJava/bin /usr/tmake/bin Edited 2003.07.27 just clean-up. Update 2003.08.03 -- A little observation regarding this old posting. The code above would never have worked in MS Win9x, which has a 127-char limit on length of command lines. I have created a revised version of it which does work on Win9x, at the cost of some additional support complexity... Update 2003.08.18 -- Refactored again since some temporary brain misfire cleared and I recalled the availability of the \l | \L operators to do what I was trying to accomplish with an eval.
Obviously this is little more than a toy, there is very little utility to it. Still, I had some fun figuring out how to code it ;-). The doubled-dollar signs ($$) in the code above are not dereferencing of anything in perl, they are there because as a macro on disk, the first $ will be eaten when the macro is read in by the Windows shell interpreter. They must be removed if the macro is input manually. | [reply] [d/l] [select] | |||