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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

require "script.pl" excecuting script

Status
Not open for further replies.

snookmz

Programmer
Apr 17, 2001
46
0
0
AU
G'day all, i hope everyone is well and jolly...

...Cause i have a problem!

Im trying to make use of some subroutines located in a script from another script through the require fuction.. Now the require function is excecuting my script when i only want to make the subroutines avaliable.. Iv tried rewriting the script im referencing so that there is nothing but subroutines, but it then complains that the script isn't returning a true value, meaning its STILL trying to excecute it..

Can someone shed some light on this for me?? Am i using the wrong function to access these subroutines??

any help will be grately appreciated, and i am very generous with my voting ;) /-------------------------------------
| I always have been, and
| always will be, a newbie :)
\-------------------------------------
 
The require function requires that the file return true. So add a '1;' to the end of the file you are requiring.
 
Thank you for the help raider, but is it possible for you to explain the syntax too me?? /-------------------------------------
| I always have been, and
| always will be, a newbie :)
\-------------------------------------
 
The required file has to return true (return a '1'). To make sure it returns a '1', the last line of the file should be:

1;

So when you require the file, each line of the file will be executed. The last line to be executed is '1;'. So the required file returns a '1'.
 
oh - and the last line of the file, the '1', is usually the only executable statement in that file that is not inside a sub... Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top