... cut ... my $str_arg = join " ",@ARGV; #remove spaces $str_arg =~ s/\s//g; @args= split /-/, $str_arg; shift @args; for my $arg (@args) { my $opt = substr($arg,0,1); switch ($opt) { case /d/ { #this is taking the value off. $options{$opt}=$arg; print "This is a database $options{$opt}\n"; } case /i/ { $options{$opt}=$arg; print "This is an instance $options{$opt}\n"; } else { print "Error arg not recognised!!!\n"; } } }