LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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
Posts: 606

Rep: Reputation: 59
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, mint, suse
Posts: 1,591

Rep: Reputation: 145Reputation: 145
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: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
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
Posts: 606

Original Poster
Rep: Reputation: 59
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: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
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



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

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:06 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration