in reply to How to get started in test first programming without writing modules? package ?

Suppose you want to write and test a function that adds number, you could do it like this:

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"; }

And run it as

$ perl foo.pl test 1..1 ok 1 - Can add two numbers $ perl foo.pl 4 6 10

Ok, the example is really lame, but it shows how you can approach the whole thing.