my $width = 80; sub process { ... } GetOptions ('width=i' => \$width, '<>' => \&process); When applied to the following command line: arg1 --width=72 arg2 --width=60 arg3 This will call "process("arg1")" while "$width" is "80", "process("arg2")" while "$width" is "72", and "process("arg3")" while "$width" is "60". #### use Getopt::Long; Getopt::Long::Configure( 'permute' ); my( $a, $b ); GetOptions( 'a!' => \$a, 'b!' => \$b, '<>' => \&process, ); sub process { ... } # call with args like -a foo bar -noa -b baz