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

Because Im working on a production pc, I cant develop or troubleshoot my last step without fear. So, I defer to the gods... I have working from cmd

START "" "C:\Users\bla-bla\myexe.exe" "C:\Users\Glenn\Desktop\test.blt +"

and need to have my.pl do the same.

#my.pl $myexe="C:/Users/bla-bla/myexe.exe"; $myfile="C:/Users/Glenn/Desktop/test.blt"; exec ('$myexe $myfile');

But that only opens a small cmd window, and doesn't launch $myexe. I didnt expect it to work, but tried

... exec '""','$myexe','$myfile';

And realize Im out of my league. Any ideas ?

Replies are listed 'Best First'.
Re: perl equiv to cmd start
by AnomalousMonk (Archbishop) on Jan 17, 2017 at 19:20 UTC
    exec ('$myexe $myfile');
    ...
    exec '""','$myexe','$myfile';

    Judging by hippo's post, it seems you may already have abandoned your post. If not, you should realize that single-quotes do not interpolate scalars (update: or anything else). E.g.,:

    c:\@Work\Perl\monks>perl -wMstrict -le "my $myexe = 'foo'; my $myfile = 'bar'; ;; my $string = '$myexe $myfile'; print qq{>$string<}; " >$myexe $myfile<
    Please see Quote and Quote-like Operators in perlop.


    Give a man a fish:  <%-{-{-{-<

      I did not abandon the post you read, Just a poorly typed previous post. As Im new to this forum, Im having trouble navigating its functions. Add to it Im having a head banging day with perl...

      I did remember that, vaguely, and thank you.

      Ultimately got it sorted out!

      $mylaunch="START \"\" \"$myexe\" \"$myfile\""; exec("$mylaunch");
        to avoid backslash-orgies like this, you might be interested in the qq function operator. The corresponding entry in perlfunc is a bit terse, but see perlop under Quote and Quote like Operators. The nice thing about it is that you can choose the delimiter that you want
        Non-bracketing delimiters use the same character fore and aft, but the four sorts of ASCII brackets (round, angle, square, curly) all nest
        Your solution could then mutate to e.g.
        $mylaunch = qq !START "" "$myexe" "$myfile"! ; exec("$mylaunch");
        (as with "normal" functions, you are allowed to have whitespace between function name and opening delimiter)
Re: perl out from batch shell
by hippo (Archbishop) on Jan 17, 2017 at 13:55 UTC