Aside from system, which was properly recommended, there are several other ways to kick off an executable file. The one you choose depends on what you want the run to do in terms of IPC and process management.

The system function launches the external program in a new process and waits for it to end before proceeding with the rest of your script. It returns only an exit status.

The exec function takes off running the new executable in the same process, leaving the rest of your script behind. It never returns unless it failed. It's useful when all you wanted to do in perl was set up some environment variables, or some other kind of initialization. It's also useful after fork.

Backticks ($out = `foo`;) launch a command and return the captured STDOUT of that command for you to use as you like.

The open function has a pair of modes, '-|' and '|-', which let you launch a command as if it were a file to read or write. Your file operations serve to read from STDOUT or write to STDIN of the command. When used this way, open returns the pid of the child process.

There are also a number of modules which deliver different flavors of these. IPC::Run, Open2, and Open3 are three which provide more extensive IPC to system- and open-like commands.

After Compline,
Zaxo


In reply to Re: Calling .exe file using perl by Zaxo
in thread Calling .exe file using perl by deepa

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.