in reply to Parsing command-line arguments in a sophisticated way.

$flag = 1 if($arr[$i] =~ /job/); ... For example, the following arguments will fail: --file job15 --dir d1 --job some-job -fw "hello"

Why not use an exact string match instead of the regex /job/? i.e. if($arr[$i] eq '--job')

Update: See also my reply to your post GetOpt unknown args, I gave you some working code there.