http://qs321.pair.com?node_id=698514


in reply to matching a line with ' and "

Have you tried Text::Balanced? Or, if quotes can't be escaped, something like (untested):
while (my ($var) = $line =~ s/^(\s*['"]+=//) { # eat single var # eat a single quoted value and its trailing whitespace. $line =~ s/^'([^']+)'\s*// || $line =~ s/^"([^"]+)"\s*// || die "invalid"; # or return, whatever you need } # if we haven't consumed all our input, this line is invalid. die "invalid" if length $line;