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 function 1

Status
Not open for further replies.

blitzer

Programmer
Jun 18, 2001
34
0
0
CA
is there any quirks in the require function or do you just use it like it seems? i mean like if i want to open some files in the middle of the perl code and i have the file opening code in a text file i just require that file where i want to open the files and it should work like a printed the open files code in the actual perl file.. it's not working like this for me.. im inserting some requires in the middle of old codes so i can edit them all at the same time rather than go into each one individually but im getting all sorts of errors.. such as in my example the files not being opened.. also 500 errors.. could anyone explain this.. ill go into detail if i must..

blitz
 
Can you give a couple examples of how you use the require statements? Also, it may seem strange, but you need to put this at the very bottom of any script you wish to 'require':

1;

Otherwise an error is returned saying something about "not returning true". This may be what's causing you script to crash. SO just to make sure you understand... if this is your 'required' script:

#===== start of script ==========

sub whatever { #blah blah blah }
# Your perl code in here

#====== End of script ===========

Then make sure that you change it to this:

#===== start of script ==========

sub whatever { #blah blah blah }
# Your perl code in here

1; # THIS NEEDS TO BE THERE AT THE END

#====== End of script ===========



Hope this helps.

--jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top