#!/usr/bin/perl use strict; use Getopt::Long; GetOptions ('demo' => \&demo, 'test' => \&Test) or die("Error in command line arguments\n"); sub demo () { die "Wrong number of args" if (scalar(@_) != 2); my $arg0 = $_[0]; my $arg1 = $_[1]; my $arg2 = $_[2]; my $arg3= $_[3]; my $arg4 = $_[4]; my $arg5 = $_[5]; print "$arg0, $arg1, $arg2, $arg3, $arg4, $arg5\n"; } sub Test () { # call the subroutine my $arg0 = $_[0]; my $arg1 = $_[1]; my $arg2 = $_[2]; my $arg3= $_[3]; my $arg4 = $_[4]; my $arg5 = $_[5]; print "$arg0, $arg1, $arg2, $arg3, $arg4, $arg5\n"; &demo("hello", "world"); } C:\temp>passparm.pl --demo demo, 1, , , , <== would expect nothing to print C:\temp>passparm.pl --test test, 1, , , , <== would expect nothing to print hello, world, , , , <== Expected C:\temp>passparm.pl --demo --test demo, 1, , , , <== would expect nothing to print test, 1, , , , <== would expect nothing to print hello, world, , , , <== Expected