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


in reply to Re^2: how to dir a directory that have space
in thread how to dir a directory that have space

works for me,
perl -we "system('dir','/b/s','/o:-d',shift)" "Program Files" C:\Program Files\Internet Explorer C:\Program Files\Microsoft Office C:\Program Files\Syncplicity C:\Program Files\McAfee C:\Program Files\WinDjView C:\Program Files\Synaptics C:\Program Files\Realtek C:\Program Files\Microsoft Silverlight C:\Program Files\Windows Journal C:\Program Files\Java C:\Program Files\Microsoft Policy Platform C:\Program Files\Common Files C:\Program Files\Lenovo C:\Program Files\Courion Corporation C:\Program Files\Windows Defender ...
indeed, there was dir.exe in cygwin in my setup that I needed to expunge before running the one-liner

Replies are listed 'Best First'.
Re^4: how to dir a directory that have space
by BrowserUk (Patriarch) on Jan 16, 2015 at 10:58 UTC

    Well I never, bless my soul, so it does. (In this case...) I stand corrected!

    On Windows, parameters are passed to executables as a single string, so the list forms of system & open etc., join the list into a single string before calling CreateProcess().

    There is some intelligence involved in the concatenation, but in many, (by my experience: most) cases, that 'intelligence' flies in the face of expectation, and gets it wrong.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked
Re^4: how to dir a directory that have space (examples)
by BrowserUk (Patriarch) on Jan 16, 2015 at 11:32 UTC

    By way of example of the inconsistent nature of the internal handling of the list form:

    system 'perl', '-E', 'say 12345;';; ## Works! 12345 system 'perl', '-E', 'say "hello world";';; ## Doesn't work. system 'perl', '-E', 'say \"hello world\";';; ## Doesn't work. system 'perl', '-E', '"say \"hello world\";"';; ## Works! hello world system 'perl', '-E', '\"say \"hello world\";\"';; ## Doesn't work, Can't find string terminator '"' anywhere before EOF at -e line 1.

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked

        I'm not sure how you draw that conclusion.

        1. system is not exec; nor vice versa.

          It is perfectly feasible and simple to invoke a command via system without going through the shell:

          [0] Perl> system q[perl -wE" say for @ARGV; <STDIN>" 1 2 "1 2" "1 \"2\ +" 3"];; 1 2 1 2 1 "2" 3
        2. That thread is very muddled.

          The conclusions drawn do not appear to match up with the code executed.

        As for Win32::ShellQuote; I've never found a need for it. I use the scalar form of system & open; quote as I would in the shell, and it just works. The problem with the list form is it does stuff to what you pass; but what it does is undocumented; thus you're always fighting 'intelligence' that isn't very.


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked
        I