can somebody tell me in which folder do we save .pm files.......can we save the .pm files in the same folder where we save .pl files?
.pm file
Collapse
X
-
Tags: None
-
For Same Directory:
we can keep .pm and .pl file in same directory
e.g;
Example.pm
Test_Example.pl
these are our .pm and .pl file
we just need to mention following thing in Test_Example.pl file,
use Example;
For Different Directory:
if we want to keep .pl and .pm in different directories,
then if you create Module directory inside your present directory to keep
your .pm files separate,
then you just need to provide the path for Example.pm file in Test_Example.pl by,
use Module::Example
here Module is directory which contains Example.pm module -
i was asking about the second option, do we need to save the .pm files inside the bin folder??
thanks for the reply.
Originally posted by rahatekarabhije etFor Same Directory:
we can keep .pm and .pl file in same directory
e.g;
Example.pm
Test_Example.pl
these are our .pm and .pl file
we just need to mention following thing in Test_Example.pl file,
use Example;
For Different Directory:
if we want to keep .pl and .pm in different directories,
then if you create Module directory inside your present directory to keep
your .pm files separate,
then you just need to provide the path for Example.pm file in Test_Example.pl by,
use Module::Example
here Module is directory which contains Example.pm moduleComment
-
If the pm file does not reside within the same folder as your script, ensure that the path is contained in @INC.Originally posted by tovenkatesh82can somebody tell me in which folder do we save .pm files.......can we save the .pm files in the same folder where we save .pl files?
Greetz, DocComment
-
hi, i created the .pm an .pl in same folder but the program shows some compilation error......
followin is the .pm file
#!/usr/bin/perl;
package calc;
use strict;
sub math{
my $value=0;
$value=$_++;
return $value;
}
1;
following is the .pl file
#!/usr/bin/perl;
use strict;
use calc qw(math);
math(5);
print $value
following error i get
global symbol $value requires package name at value.pl at line 5.
Originally posted by rahatekarabhije etFor Same Directory:
we can keep .pm and .pl file in same directory
e.g;
Example.pm
Test_Example.pl
these are our .pm and .pl file
we just need to mention following thing in Test_Example.pl file,
use Example;
For Different Directory:
if we want to keep .pl and .pm in different directories,
then if you create Module directory inside your present directory to keep
your .pm files separate,
then you just need to provide the path for Example.pm file in Test_Example.pl by,
use Module::Example
here Module is directory which contains Example.pm moduleComment
-
can someone resolve this error......
hi, i created the .pm an .pl in same folder but the program shows some compilation error......
followin is the .pm file
#!/usr/bin/perl;
package calc;
use strict;
sub math{
my $value=0;
$value=$_++;
return $value;
}
1;
following is the .pl file
#!/usr/bin/perl;
use strict;
use calc qw(math);
math(5);
print $value
following error i get
global symbol $value requires package name at value.pl at line 5.Comment
-
You didn't need to repost this same question. The reason the code fails is because it is incomplete. There are a few ways to get it to work. Here is one way:
main script:
Calc.pm:Code:#!perl; use strict; use Calc; my $value = math(5); print $value;
Code:package Calc; use strict; require Exporter; our @ISA = qw(Exporter); our @EXPORT = qw(math); sub math { my $value = shift; $value++; return $value; } 1;Comment
-
it does not works it gives an error saying"undefine d subroutine &main::math called at value.pl line 5.
Originally posted by KevinADCYou didn't need to repost this same question. The reason the code fails is because it is incomplete. There are a few ways to get it to work. Here is one way:
main script:
Calc.pm:Code:#!perl; use strict; use Calc; my $value = math(5); print $value;
Code:package Calc; use strict; require Exporter; our @ISA = qw(Exporter); our @EXPORT = qw(math); sub math { my $value = shift; $value++; return $value; } 1;Comment
-
Comment