#!/usr/bin/perl # first attempt, non-working as the # long option is also discounted use strict; use warnings; use Getopt::Long qw( :config posix_default gnu_compat bundling no_auto_abbrev no_ignore_case ); my $column = 1; #print map "[$_]", @ARGV, "\n"; #exclude the unwanted format with a filtering grep @ARGV = grep $_ !~ /\A--c=/, @ARGV; # remove the offending format using substition operator and test to see if you did # if( grep s/\A--c=.*//, @ARGV ){ $column = 100 }; #print map "[$_]", @ARGV, "\n"; GetOptions( 'column|c=i' => \$column, ) or die; print "\$column is $column\n"; die if $column < 1; __END__ $ ~/Desktop/gol.pl --column=2 $column is 2 $ ~/Desktop/gol.pl -c2 $column is 2 $ ~/Desktop/gol.pl --c=2 $column is 1 $ ~/Desktop/gol.pl -c=2 Value "=2" invalid for option c (number expected) Unknown option: = Unknown option: 2 Died at ~/Desktop/gol.pl line 19. # using grep and substitution as conditional $ ~/Desktop/gol.pl --c=2 $column is 100 #but also doesnt allow $ ~/Desktop/gol.pl --column 2 $column is 1