Re: Running perl from a test on Windows

Gabor Szabo <[email protected]>
Newsgroups gmane.comp.lang.perl.quality-assurance
Message-ID <CABe4FJB_0NOfEHvU7T5_kdG=QZQ+E7+Cem-o+45cm1W+KtQ=aQ@mail.gmail.com>
On Mon, Jan 14, 2013 at 9:59 PM, Buddy Burden <[email protected]> wrote:
> Guys,
>
> Okay, my Google-fu is failing me, so hopefully one of you guys can help me out.
>
> For a test, I need to run a snippet of Perl and collect the output.
> However, if it rus in the current interpreter, it will load a module
> that I need not to be loaded ('cause I'm also going to test if my code
> properly loads it).  So I want to run it in a separate instance of
> Perl.
>
> First (naive) attempt:
>
>     my $output = `$^X -e '$cmd'`;
>
> This works fine on Linux, but fails on Windows.  Happily, as soon as I
> saw the failures, I recognized I had a quoting problem.  No worries, I
> said: let's just bypass the shell altogether:

I am not sure if this helps but in Windows you need to put the
double-quotes around  $cmd

    my $output = qx{$^X -e "$cmd"};

and of course inside $cmd you should use single quotes and not double
quotes if you need
some quotation.

Oh the joy :)

Gabor
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.