in reply to Road to a readable path

On Windows, you don't even need Perl to get a readable path:

for %i in ("%path:;=" "%") do @echo %i

Produces this (for my path):

{C} > for %i in ("%path:;=" "%") do @echo %i "C:\usr\bin" "C:\Perl\bin" "C:\WINDOWS\system32" "C:\WINDOWS" "C:\WINDOWS\System32\Wbem" "c:\Program Files\Microsoft SQL Server\90\Tools\binn\" "C:\Documents and Settings\Administrator\My Documents\bin" {C} >

UPDATE: Use "set /?" at the command prompt to find out the new options for environment variable substitution (the %path:;=" "%). Basically, I wrap the %PATH% ENV var in double quotes and then replace all the semicolon separators with a double-quote, space, double quote. This effecitely puts double quotes around all the paths (so spaces won't give any troubles) and we use the for loop to list each newly double-quoted string

Replies are listed 'Best First'.
Re^2: Road to a readable path (unix, non-perl)
by toolic (Bishop) on Apr 15, 2009 at 14:07 UTC
    Nor on unix...
    $ echo $PATH | tr ':' '\n'
      echo -e ${PATH//:/\\n}

        Unadorned echo may or may not support a particular option, dependent on if it is a shell (which one?) built in or an external command. See the start & the bottom of GNU echo invocation; mix in korn-shell (sic) for extra fun.

        Variable expansion(substitution) is also shell dependent ...

        • generates error ${PATH/...}: Bad substitution in FreeBSD 6 /bin/sh (ash);
        • generates error Missing } in tcsh 6.15*;
        • at least works in zsh 4* & bash 3* here.
Re^2: Road to a readable path
by Burak (Chaplain) on May 11, 2009 at 21:10 UTC
    On Windows, you don't even need Perl to get a readable path
    Yeah, but you have to do it in a sucky way :p FYI: when you install perl, you also get the "pl2bat" program (it's actually there to support module installation process I believe) to turn your perl programs into *.bat, so that you don't have to write that dumb basic-ish thing to have general purpose commands on you system.