×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

including other perl files

including other perl files

including other perl files

(OP)
I'm rather new to perl. I wan to know how to include other perl scripts into my perl script. For example, I have a file called 'website.pl' that has all of my nifty perl subs that I use. Then I write a script in 'newsupdate.pl' and I want to use the subs from the 'website.pl' file.

I'd rather NOT make this a package and just do something like #include <website.pl> but if I must make it a package let me know.

Thanks,
Joh

RE: including other perl files

Unless you have a specific reason for not making it a package, it's pretty easy.

package myPackage;


sub a...

sub b...


1; #It must return true...

then, in your main file, just do:
use myPackage;

and all of your subs will be avalible in the scope of the program.  If you need clearer syntax, just let me know.  I'm at home now and all of my references are at work...

Good Luck

RE: including other perl files

(OP)
That's cool, actually I like that method because I have to prefix my calls.

myPackage::FuncA;

Is there a way to have FuncA within the scope of the main perl file so you can just

FuncA;

I don't really need it, I like the other method, but Iw as just wondering ;)

John

RE: including other perl files

i believr you can use:

require website.pl;


then you should be able to use all your sub routines normally

RE: including other perl files

You could Also make them modules and subroutines.  Doing that you could keep all of the variable names private and seperate by using 'my var1;' and so on. I do this for parsing the input variables since I do it in every cgi script

Miah

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close