#!/usr/bin/perl use Getopt::Std; getopts('xp', \%opt); $arg_1 = $opt{'x'} if (defined($opt{'x'})); $arg_2 = $opt{'p'} if (defined($opt{'p'})); sub test_a { print "argument is from $arg_1\n"; } sub test_b { print "argument is from $arg_2\n"; }