CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
calling routines from a different script

 



Zeke_D
Deleted

Oct 26, 2000, 8:50 PM

Post #1 of 5 (658 views)
calling routines from a different script Can't Post

How do I call a subroutine from another script?

for example,
i am using script1 for registering that contains a routine called &foo

i want to call &foo from script2

is it a require line or something?

require "script1";
&foo;


perlkid
stranger

Oct 26, 2000, 8:55 PM

Post #2 of 5 (658 views)
Re: calling routines from a different script [In reply to] Can't Post

 Why'd ya question your guess,

Your right, Using require ""; you can carry all of the variables, subs, and arrays over to script2.

If your on windows, real path is required, Unix/Linux then you can just leave it as it is with only the script's name, that's if the file your requiring is in the same directory as script1. If not, then full path is needed.

[This message has been edited by perlkid (edited 10-26-2000).]


Zeke_D
Deleted

Oct 26, 2000, 8:59 PM

Post #3 of 5 (658 views)
Re: calling routines from a different script [In reply to] Can't Post

would this also work for &readparse?


perlkid
stranger

Oct 26, 2000, 9:48 PM

Post #4 of 5 (658 views)
Re: calling routines from a different script [In reply to] Can't Post

 
Yes, any subroutine at all will be carried through at your request. At your request meaning

require "script1.pl";
&readparse;
print "$form{'text'}";

perlkid


Cure
User

Oct 27, 2000, 10:15 AM

Post #5 of 5 (658 views)
Re: calling routines from a different script [In reply to] Can't Post

perldoc -f require


Cure

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives