I often use the quick and dirty approach of just using back-tics to make a
system call to my other perl script (or program) and grab its output for my
own program

like this:

#!/usr/bin/perl -w
#my first script

#initialize a variable to pass
$x="foo";

#call 'secondScript.pl' with "foo" as an arg
$result = `perl secondScript.pl $x`;  

print $result;


###################################
#!/usr/bin/perl -w
#secondScript.pl

print shift()."bar";

#####################################


So, my final result is "foobar"

You can call any script or outside program this way.

If you don't care about the return result of your program, you could use
"exec()"
or, if you need to make sure the program exited sucesfully and you want to
fork a new process for it, use "system()"

run 'perldoc -f system' and 'perldoc -f exec' for details.

-peter


-----Original Message-----
From: debraj bhattacharyya [mailto:debraj_rec@;sify.com]
Sent: Thursday, November 14, 2002 3:26 AM
To: Olympio Raymond
Cc: beginners
Subject: Re: running a perl script in an other one ?


hi 

You can definitely connect two perl scripts.One example is passing the
scriptname of one program as argument to the second one.But the same thing
can be very easily done with the help of functions as in modular
programming.

do get back if i am not clear
thanx
raj

____________________________________________________________

 Olympio Raymond <[EMAIL PROTECTED]>:

> Hi everybody,
> Im a new in perl programming so i hope you wont find my question too 
> stupid. I have to run a some user-defined functions, but i dont want to
> 
> include them in only one script. So, is it possible to run a perl script
> 
> into an other one ?
> Thanks
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

-------------------------------------------------
Sify Mail - now with Anti-virus protection powered by Trend Micro, USA.
Know more at http://mail.sify.com

Want to get into IIM? Take the Sify Mock CAT now!
http://education.sify.com/mockcat

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to