LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 01-26-2011, 02:13 PM   #1
devUnix
Member
 
Registered: Oct 2010
Location: Bengaluru, India
Distribution: RHEL 5.1 on My PC, & SunOS / Sun Solaris, RHEL, SuSe, Debian, FreeBSD and other Linux flavors @ Work
Posts: 549

Rep: Reputation: 46
Perl Module and Calling Functions of Another Perl Source File


When do we name a Perl source/code file .pm and .pl?

Examples:

Sample.pm
Sample.pl

And also how do we include a Perl source/code file into another one?

Example:

first.pl calls the functions written in second.pl

Any help?

Note: I just found we can use the use directive, and that .pm is for using functionality of a Perl Module within in a Perl source/code file.

I am leaving this threas as open just for the gurus out here to throw more light upon the subject; or whatever they would like to add to it from their experience.

Last edited by devUnix; 01-26-2011 at 02:46 PM. Reason: Got it!
 
Old 01-27-2011, 03:22 AM   #2
j-ray
Senior Member
 
Registered: Jan 2002
Location: germany
Distribution: ubuntu
Posts: 1,415

Rep: Reputation: 99
A perl module is a more or less complex project that may consist of several files with a central .pm. Her's a howto: http://mathforum.org/~ken/perl_modules.html
If I don't mix it, you can use

require '2ndfile.pl';

...if you want to include some functions from 2ndfile.pl
 
1 members found this post helpful.
Old 01-28-2011, 03:58 AM   #3
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by devUnix View Post
...they would like to add to it from their experience.
Read the documentation. I.e. start from http://perldoc.perl.org/ .

At all, RTFM:

Code:
man perl
- among other things you'll see:

Code:
           perlmod             Perl modules: how they work
           perlmodlib          Perl modules: how to write and use
           perlmodstyle        Perl modules: how to write modules with style
           perlmodinstall      Perl modules: how to install from CPAN
           perlnewmod          Perl modules: preparing a new module for distribution
.
 
Old 01-28-2011, 01:42 PM   #4
devUnix
Member
 
Registered: Oct 2010
Location: Bengaluru, India
Distribution: RHEL 5.1 on My PC, & SunOS / Sun Solaris, RHEL, SuSe, Debian, FreeBSD and other Linux flavors @ Work
Posts: 549

Original Poster
Rep: Reputation: 46
Thanks!

Please, change your signature line "If Python don't have..." to "If Python doesn't have..."
 
Old 01-28-2011, 03:53 PM   #5
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by devUnix View Post
Thanks!

Please, change your signature line "If Python don't have..." to "If Python doesn't have..."
My signature is a literal quote; since it's a quote, I can't change it.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
list perl module & install perl module DBD::mysql linson_85 Linux - Newbie 4 06-22-2009 10:42 AM
Perl module Compress::Zlib installed but perl not detecting it danran Programming 0 05-03-2007 01:50 PM
Calling KDE/C++ functions from python/perl and vice versa yogeshm02 Programming 1 04-30-2005 11:54 AM
Problem with perl module for w3c validator to work on my local Apache+PHP+perl instal tbamt Linux - Software 0 12-16-2004 05:37 PM
perl(Cwd) perl(File::Basename) perl(File::Copy) perl(strict)....What are those? Baldorg Linux - Software 1 11-09-2003 08:09 PM


All times are GMT -5. The time now is 04:53 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration