Fellow Monasterians,
I'm discovering the benefits of reusable code. My question is this: do I have to put the code in a package or can it just be a file that ends with 1;? I have done it both ways, but the package method requires a little extra code. I have read in Programming Perl that the package method protects the namespaces, but what else? Thanks.
Main (without using package):
use Common.pm; my $returnvalue = somesub();
Common.pm:
sub somesub { ...create value... return($value); } 1;
Main (with package):
use Common.pm; my $returnvalue = Common->somesub();
Common.pm:
package Common; sub somesub { ...create value... return($value); } 1;
In reply to Package vs. plain file by bradcathey
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |