Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 20-06-2009
Member
 
Join Date: May 2008
Posts: 69
Need Perl script to execute from another.

Hi,

I am new with PERL programming.
I have a question. Is it possible to call a Perl script from an another script. The problem is how to get a response from the script?

Any help will be appreciated.
Reply With Quote
  #2  
Old 20-06-2009
Member
 
Join Date: Jan 2009
Posts: 43
Re: Need Perl script to execute from another.

This will call a new perl process, and may be more expensive on the
Code:
system. On the other hand I can do
Code:
But How do I get the response of the script.
Probably the dimpliest way is to make called script a module and run it
using either 'use' or 'require'.
If you care about speed, consider using do 'filename.pl', which will avoid firing up a new Perl interpreter.
Reply With Quote
  #3  
Old 20-06-2009
Member
 
Join Date: Jan 2009
Posts: 40
Re: Need Perl script to execute from another.

I think you can do the following;
1. backticks: $retVal = `perl somePerlScript.pl `;
2. system() call
3. eval
The eval can be accomplished by slurping the other file into a string (or a list of strings), then 'eval'ing the strings
Code:
#!/usr/bin/perl
open PERLFILE, "<somePerlScript.pl";
undef $/;   # this allows me to slurp the file, ignoring newlines
my $program = <PERLFILE>;
eval $program;
4. do:
Code:
do 'somePerlScript.pl'
For more discussion.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags:



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Need Perl script to execute from another."
Thread Thread Starter Forum Replies Last Post
How to run Perl script on Mozilla Firefox? Grayson Software Development 5 02-11-2011 02:35 PM
Firefox problem with perl script Gajendra1 Software Development 6 09-09-2010 04:44 PM
How to call perl script from Python? Jhonwho Software Development 3 23-07-2009 09:59 PM
Is it possible to execute Perl script within another script? RasMus Software Development 2 21-07-2009 10:57 PM
Title of a Perl CGI script !const Software Development 2 26-03-2009 11:43 PM


All times are GMT +5.5. The time now is 04:13 AM.