use strict; Splice_Array("--config"); Splice_Array("--enter"); sub Splice_Array { print "Before Array Splicing: \n"; print "\t" . join(',', @ARGV), "\n"; my $value=shift; print "Splicing Value: $value\n"; my @matches = grep { $ARGV[$_] eq $value} 0..$#ARGV; # Just to Count the number of times the variable was identified print "$value is located at index(s): " . join(',', @matches), "\n"; for my $match (@matches) { # just used for a Max loop count my @index = grep { $ARGV[$_] eq $value} 0..$#ARGV; print "Index:$index[0]\n"; splice @ARGV, $index[0] ,1; } print "After Array Splicing: \n"; print "\t" . join(',', @ARGV), "\n\n\n"; }