arunmep has asked for the wisdom of the Perl Monks concerning the following question:

Iam executing windows find command using backtik qx// ia have file that have space between them so when i try to run the command it tries to separate the file names and executing it can anybody give a solution for this thank you

2006-10-09 Retitled by GrandFather, as per Monastery guidelines
Original title: 'hi'

  • Comment on Backtick execution with spaces in filename

Replies are listed 'Best First'.
Re: Backtick execution with spaces in filename
by shmem (Chancellor) on Oct 09, 2006 at 05:47 UTC
    Quote your arguments, eg:
    perl -le "$f = qx/cat 'Some File.txt'/; print $f"

    <update>
    Oops... strange mixture of Windows outer quoting and UNIX inner quotings and commands - thanks cdarke ;-)

    perl -le "$f = qx/type \"Some File.txt\"/; print $f"
    I rarely use Windows...;-)
    </update>

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
      Sorry, but that won't work on Windows because the quoting on cmd.exe is picky compared to a UNIX shell. The following works:
      perl -le "$f = qx/type \"this is a name.pl\"/;print $f"
        Sorry, I did not intend to be Anonymous above, my browser lost my login for some reason.