The elephant that's been mentioned only implicitly is 'doze-style quoting.'

Sorry, this illustration (which presents two ways of working with Win32) is a bit on the long side but here goes, anyway...

#!/usr/bin/perl use strict; use warnings; use 5.018; # #1107536 my $program="D:\\GnuWin32\\bin\\ls.exe"; print "$program\n"; runit ($program); sub runit { system ("$program"); if ($? == -1) { print "failed to execute: $!\n"; } say "\n\t DEBUG: reached the end of sub runit at Ln23"; sleep 1; } say "\n Done with first sub, back in main. \n"; my $path = 'D:/GnuWin32/bin/'; my $pgm="ls.exe"; my $cmd ="$path" . "$pgm"; runit2 ($cmd); sub runit2 { say "\n\tEntering runit2\n"; sleep 3; my ($cmd_in_sub) = @_; say "\n\t DEBUG: $cmd_in_sub\n"; system ("$cmd_in_sub"); if ($?) { print "failed to execute: $!\n"; } } say "\n Done with second sub ";

Execution:

D:\>D:\_Perl_\PMonks\1107536NON-GUI.pl d:\_wo D:\GnuWin32\bin\ls.exe .. TestFiles Connexions tbos.css CPM-ZCPR ViennaProtocol.txt created_psp_files WinSHAetc DEBUG: reached the end of sub runit at Ln23 Done with first sub, back in main. Entering runit2 DEBUG: D:/GnuWin32/bin/ls.exe ... TestFiles Connexions tbos.css CPM-ZCPR ViennaProtocol.txt created_psp_files WinSHAetc.... Done with second sub D:\>

M$Win mistreats (file and/or dir)_names_with_spaces unless the whole Path/Program_name match is double-quoted.

NB: This also works to invoke a Windows GUI program, such as Chrome or Beyond Compare.

Updated: by removing extraneous code; adding note


In reply to Re: 'C:\Program' is not recognized as an internal or external command, operable program or batch file. by ww
in thread 'C:\Program' is not recognized as an internal or external command, operable program or batch file. by prab2112

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.