Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Perl Calling Perl! :P

by dudydude (Novice)
on Jul 22, 2011 at 02:31 UTC ( #916042=perlquestion: print w/replies, xml ) Need Help??

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

Hey Monks, I have a quick question. I wrote a Perl Script on Win Environment and I wonder if I can make this Perl Script call another Perl script? Of course all in Win environment. If it is possible, can you teach me? Thanks :P

Replies are listed 'Best First'.
Re: Perl Calling Perl! :P
by ww (Archbishop) on Jul 22, 2011 at 03:12 UTC
    See perldoc for system and exec and backticks (`) ...
    or use a search tool... Google, Super Search or your fav...
    and don't forget to check out Tutorials and Q&A sections here.

    This is really to sort of question for which you need to start finding answers yourself (by use of tools like those cited and the rich resources here). Once you've done that, you'll find the Monks generous with explanations when you hit a stumbling block whose solution lies beyond the basics.

Re: Perl Calling Perl! :P
by cdarke (Prior) on Jul 22, 2011 at 07:04 UTC
    One thing to be careful of when running Perl scripts from Perl on Windows (or any other similar language from Windows) is that file association is only done by a shell, like cmd.exe or Windows Explorer. So, if you call system(''); then it probably won't work, since perl will not invoke a shell which it considers unnecessary.

    There are several solutions. The simplest is just system('perl'); but that assumes that %path% is set correctly. You could specifically invoke cmd.exe, or, to take an extreme, use Win32::FetchCommand which will do the registry lookup required for file association.

    UNIX style operating systems don't have this issue because of the #! line.

      Or you can use $^X

      system($^X, '');
Re: Perl Calling Perl! :P
by Anonymous Monk on Jul 22, 2011 at 03:45 UTC
Re: Perl Calling Perl! :P
by zentara (Archbishop) on Jul 22, 2011 at 12:16 UTC
    You don't say whether you want to wait for the called script to return, before moving on, or whether you want the executed script to run in a non-blocking manner. But if you don't need or want to wait for the spawned script to return, see Re: Running a process in the background for the Windows only trick of system 1, $script;

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://916042]
Approved by ww
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2021-04-23 03:13 GMT
Find Nodes?
    Voting Booth?

    No recent polls found