use strict; use warnings; use Getopt::Long; GetOptions( 'demo' => \&demo, 'test' => \&test ) or die("Error in command line arguments\n"); sub demo { my ( $arg0, $arg1, $arg2, $arg3, $arg4, $arg5 ) = @_ ; warn "Number of args: ", scalar @_; die "expected 2 args" if @_ != 2; warn join ",",@_; } sub test { die "expected 2 args" if @_ != 2; warn join ",",@_; demo("hello", "world"); } #### test,1 at d:/tmp/pm/getopt_long.pl line 23, line 26. Number of args: 2 at d:/tmp/pm/getopt_long.pl line 16, line 26. hello,world at d:/tmp/pm/getopt_long.pl line 18, line 26.