From: Mark W. <mew...@un...> - 2000-05-24 13:52:17
|
Hi, here's the error message (I added some debug info so we can see what the original value was before the regex) Failed to parse token from value [] with ( objectclass $ ou ) MAY ( aci $ busin esscategory $ description $ destinationindicator $ facsimiletelephonenumber $ in ternationalisdnnumber $ l $ physicaldeliveryofficename $ postofficebox $ postala ddress $ postalcode $ preferreddeliverymethod $ registeredaddress $ searchguide $ seealso $ st $ street $ telephonenumber $ teletexterminalidentifier $ telexnum ber $ userpassword $ x121address $ nsadmindomainname ) ) at d:/Perl/site/lib/Net /LDAP/Schema.pm line 436. This is schema from iPlanet 4.1. I'll try to take a look at your suggestions tonite and see what I come up with. BTW Thanks to those who sent me NT GNU URLs. There's also a diff.pl as part of the Perl Power Tools. Mark Graham Barr wrote: > 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. |