use strict; use warnings; use Getopt::Long; GetOptions( 'demo' => \&demo, 'test!' => \&test ) or die("Error in command line arguments\n"); sub test { die "expected 2 args" if @_ != 2; warn join ",",@_; # demo("hello", "world"); } __DATA__