use strict; use Getopt::Long; my $Input_File=0; my $Ip_Range=0; GetOptions('InputFile|i=s' => \$Input_File 'Ip|I=s' => \$Ip_Range); if ($Input_File xor $Ip_Range) { # We have one or other of the input options given in the command line. } else { no valid input print usage. }