Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

use another script in a script

Status
Not open for further replies.

donny750

Programmer
Jul 13, 2006
145
FR
hello,

I've script A.pl who modify something;

I want to use this script in another script B, because i call 3 times the script A for modifiying things.

It's possible in perl to do this ?

May be something like this :

B.pl
code...
i call the script A.pl with parameter :
A.pl -filename xx.csv

code ..
i call another times the script A.pl :
A.pl -filename vb.csv

code ...

Thanks
 
Make a function inside B.pl to handle this:

Code:
callA('xx.csv');
callA('cb.csv');

sub callA {
	local @ARGV = ('-filename', @_);
	do 'A.pl';
	# Read docs to add error checking: [URL unfurl="true"]http://perldoc.perl.org/functions/do.html[/URL]
}

If you want to add error checking for the parsing and executing of A.pl, just read the docs provided with the do function. And obviously, you should probably give "callA" a better name.

- Miller
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top