Solution with namespace
#!/usr/bin/perl
use strict;
use warnings;
require "examples/modules/namespace_lib.pl";
print Calc::add(3, 4), "\n";
package Calc;
use strict;
use warnings;
my $base = 10;
sub add {
validate_parameters(@_);
my $total = 0;
$total += $_ for (@_);
return $total;
}
sub multiply {
}
sub validate_parameters {
die 'Not all of them are numbers'
if grep {/\D/} @_;
return 1;
}
1;
Here, within the Calc namespace you don't have to use the full name, only when you are using it outside.