use Getopt::Long; GetOptions( 'ip=s' => \my $ip, ); print $ip; #### perl yourscript.pl --ip=192.168.0.1 perl yourscript.pl --ip 192.168.0.1