From: Graham B. <gb...@po...> - 2000-05-24 09:12:09
|
On Tue, May 23, 2000 at 07:19:38PM -0500, Mark Wilcox wrote: > Hi, > I've been playing with Net::LDAP::Schema on version .018 of Net::LDAP. > Discovered that it kept crashing for my test script at Schema.pm line > 433. > > This was > ( $token, $value ) = $value =~ > /^[\s,]*(["']?[^"'\s()]+["']?[,\s]*)(.*)$/; > die( "Failed to parse token from value [$value]" ) unless $token; Can you send what $value was to start with ? Was it legal ? > I changed to > ( $token, $value ) = $value =~ > /^[\s,]*(["']?[^"'\s()]+["']?[,\s]*)(.*)$/; > last unless $token; > die( "Failed to parse token from value [$value]" ) unless $token; > > that seems to have fixed it. Hm, that should have given an error. That code is in a do{} block and last cannot be used to exit a do{} block. I think that block would be better written as while($value =~ s/^[\s,]*(["']?[^"'\s()]+["']?[,\s]*)//) { $word .= $1 @quotes = $word =~ /(["'])/g; # broken emacs '"])/; last unless @quotes & 1; # Until even num of quotes } However, we can do better. @quotes = $word =~ /(["'])/g; last unless @quotes & 1; could just be last unless $word =~ tr/"'// & 1; But I think it could also be done with $value =~ s/^[\s,]*((["']?)(\\.|[^"'()\\]+)*\2)// or die "..."; However back to the initial problem, the die ... I think the die is probably the correct thing, but it should be caught by an eval {} in new() and have new() return an error. Having said that, currently ::Schema just warns and returns undef. It probably should do better than that. So I am open to suggestions. That goes for all other modules too. Graham. |