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".