in reply to I really need help making a module.
Make sue they are in the appropriate directories too.package Your::Package;
This is what i have at the top of my modules:
package My::Module; use Exporter qw(import); @EXPORT_OK = qw(sub names here);
An example:
package My::Package; use Exporter qw(import); @EXPORT_OK = qw(print_lines); use strict; use warnings; sub print_lines{ my ($input) = @_; while(my $lines = <$input>){ print $lines; } }
And call it from you script like:
use strict; use warnings; use My::Package qw(print_lines); open my $file, '<', shift; print_lines($file);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: I really need help making a module.
by adur (Initiate) on Aug 19, 2015 at 16:15 UTC |