#!/usr/bin/perl

package Main; # declare package

use strict;
use warnings;
use Getopt::Long;

# treat as package unless called from cmd line
__PACKAGE__->main(@ARGV) unless caller();

sub main {
    my %opts = ();
    GetOptions (
        \%opts,
        "name=s",
    );
    if (exists($opts{name}) && $opts{name} eq "foo") {
        foo();
    } else {
        print "I don't know what to do!\n";
        return 1;
    }
    return 0;
}

sub foo {
    print "Foo was called!\n";
    return 42;
}
