#!/usr/bin/perl

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

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";
    exit(1);
}
exit(0);

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