#!/usr/bin/perl

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

sub main {
    my %opts = (); # save all cmd line opions in this hash
    GetOptions ( # read cmd line args
        \%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;
}

exit(main());
