sub dequote { local *_ = \$_[0]; s/^"(.*)"$/$1/; s/\\(.)/$1/g; } if ($line =~ m/ -([^\S"\\]+) # An dashed identifier (?: # optionally followed by \s+ # whitespace ( # and either "(?:[^"\\]|\\.)*" # a quoted string | # or [^\S"\\]+ # a bare identifer. ) )? /x) { my ($opt, $arg) = ($1, $2); dequote($arg); $DATAFROMBATCHFILE[$counter]{$opt} = $arg; } elsif ($line =~ m/\bEND\b/) { $counter ++; }