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__ #### C:/Strawberry/perl/bin\perl.exe -w d:/tmp/pm/getopt_long.pl --no-test test,0 at d:/tmp/pm/getopt_long.pl line 16, line 28.