use strict; use warnings; sub add { $_[0] + $_[1] }; if (defined $ARGV[0] && $ARGV[0] eq 'test') { use Test::More; plan tests => 1; is add(1, 2), 3, 'Can add two numbers'; } else { print add(@ARGV), "\n"; } #### $ perl foo.pl test 1..1 ok 1 - Can add two numbers $ perl foo.pl 4 6 10