Skip to content

Instantly share code, notes, and snippets.

@Util
Created October 1, 2009 04:01
Show Gist options
  • Save Util/198715 to your computer and use it in GitHub Desktop.
Save Util/198715 to your computer and use it in GitHub Desktop.
Util's own stripped-down and modernized example of how to make a module.
package CoolMod;
# Util's own stripped-down and modernized example of how to make a module.
# File must be named CoolMod.pm
# Usage: `use CoolMod qw( foo bar );`
use strict;
use warnings;
use base qw(Exporter);
our $VERSION = 1.00;
our @EXPORT_OK = qw( &foo &bar );
sub foo {
print "foo got @_\n";
}
sub bar {
print "bar got @_\n";
}
1; # Mandatory!
#!/usr/bin/perl
use strict;
use warnings;
use CoolMod qw( foo bar );
foo( 'Hello', 99 );
bar( 'Hi', 'Max' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment