About using required files

Ken Elliott's picture

They have: 358 posts

Joined: Jun 1999

When you have a required file, (require "somefile.cgi") can u put $scalars in it and call them from the file, just like they were in the script?

I mean, like create a text file, that all of the scalars I will use, with their intended values. Then require it from all the files using those scalar values, and then use those scalar values in the script?

Thanks for the help.
VulKen

DiggyDogStyle

Pimpin like a pimp with an electrofied pimpin machine!

They have: 568 posts

Joined: Nov 1999

yes you can

an example would be

#!/usr/bin/perl
require "test.pl";
print $test;

and test.pl would contain
$test = "hello";

so when you ran the program it would print "hello"

I just learned that myself. Smiling

Ken Elliott's picture

They have: 358 posts

Joined: Jun 1999

Hmm... I am having problems with it. Well atleast I know it is something on my part, and not the inability to do it. Does it have to be .pl or can it be .cgi? I also see it in my book as .lib. I will try them all, minus well. I am trying everything anyway.

VulKen
Gimme that donkeybutt?

Pimpin like a pimp with an electrofied pimpin machine!

They have: 568 posts

Joined: Nov 1999

No, extension on the require file doesn't matter.

They have: 568 posts

Joined: Nov 1999

Also, if you are using subroutines in the include file you'll need to put 1; at the end or it wont work.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.