Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

i need help in subroutines

by uva (Sexton)
on Feb 07, 2006 at 11:21 UTC ( [id://528470]=perlquestion: print w/replies, xml ) Need Help??

uva has asked for the wisdom of the Perl Monks concerning the following question:

i want to know how to create one subroutine in one file and using that in another file.... do we need "use" keyword for importing the moodule... i saw in one code they r using &module1::text($MAXDIR);...what does it mean.. If u code for me, it will be helpful for me.. thank you very much.

Replies are listed 'Best First'.
Re: i need help in subroutines
by Corion (Patriarch) on Feb 07, 2006 at 11:31 UTC

    Hello and welcome to the monastery, uva!
    Perl itself comes with extensive documentation, but I think you are better helped by learning Perl through an introductory book like merlyn's Learning Perl or Programming Perl (the "Camel Book"). Especially if you already know another programming language (for example C or C++), that book should help you.

      thanx for the reply Corion.... i read "the subroutines are written and store in the file with extension .pm and we can use that subroutine in someother file using -use module;- i tried to implement it is giving error as -cannot locate module in @INC- i also tried using push(@INC,"d:\\module.pm") but still it is giving error,,,,, thats why i asked one code..."

        The @INC array is for storing directories in which Perl looks for your modules. If you have a file UvaModule.pm in the directory D:\uva\code\, then you can load it with:

        use lib 'D:/uva/code/'; use UvaModule;

        Read the lib documentation.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://528470]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2025-01-14 06:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which URL do you most often use to access this site?












    Results (38 votes). Check out past polls.