Please bottom post... > You can execute that second script: > require script.pl > > or > > system('perl script.pl'); >
While interesting solutions I would avoid both. The first is a very odd usage of require to me, if you want to go along those routes I suspect you are better off with do or eval. *Unless* you need the specific functionality of 'require' aka version checking and/or preventing multiple uses (which is likely something to avoid). From the 'require' docs: "The file is included via the do-FILE mechanism, which is essentially just a variety of "eval"." perldoc -f do perldoc -f require perldoc -f eval There are *lots* of reasons to avoid the second, speed, error proneness, and security are probably the best 3. If you are going to consider using it, then you are possibly going to want to use backticks instead to catch STDOUT to make sure it is handled properly, but you are certainly going to want to use a full path to the command, probably don't need to bother with calling perl (if you are going to, use the full path!) (unless you are on windows), and provide the necessary error catching through the use of $?, etc. which is why this simple answer is such a bad one, by the time you wrap it in the proper checks it becomes easier to take your original script, suck out the common parts and turn it into a real library. But those are just my rants, do what you will..... http://danconia.org > ----- Original Message ----- > From: "Kenneth W. Craft MCP" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Wednesday, January 14, 2004 3:06 PM > Subject: Script within a script > > > > Is it possible to execute a perl script within another perl script? > > > > I have advertisements on many of my pages of my site that are randomly > > picked using a random ad script. I am creating some pages that are > > dynamically being created, and I can't use ssi to pull the ads into the > > page (right now on my main page I use <!--#exec cgi --> to call the ad > > scripts. > > > > Thanks > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>