Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Testing a simple Perl module

We have a module called MySimpleCalc.pm with a single function called sum(). It is supposed to return the sum of numbers passed to it.

package MySimpleCalc;
use strict;
use warnings;

use Exporter qw(import);
our @EXPORT_OK = qw(sum);

sub sum {
    return $_[0] + $_[1];
}

1;

  • sum(1, 3)