Hi,
On Friday 23 April 2004 09:28, Claude wrote:
> >>>>> "Peter" == Peter Marschall <[EMAIL PROTECTED]> writes:
> $ ./test0.pl
> Never printed at ./test0.pl line 9.
> Can't call method "error" without a package or object reference at
> ./test0.pl line 13.
>
> Or, with the debugger:
>
> main::(./test0.pl:7): my $schema = Net::LDAP::Schema->new;
> DB<1> n
> main::(./test0.pl:9): $schema->parse( "foobar" )
> main::(./test0.pl:10): or warn "Never printed";
> DB<1> n
> Never printed at ./test0.pl line 9, <IN> chunk 2.
> main::(./test0.pl:12): my $r = $schema->parse( "foobar" );
> DB<1> n
> main::(./test0.pl:13): warn "This is printed" if $r->error();
> DB<1> n
> Can't call method "error" without a package or object reference at
> ./test0.pl line 13, <IN> chunk 4.
> DB::fake::(/opt/local/lib/Perl5.004_04/lib/perl5/perl5db.pl:2083): 2083:
> "Debugged program terminated. Use `q' to quit or `R' to restart.";
>
> IMO, that tells that:
>
> - $schema->parse( "foobar" ) now returns undef which is ok, according
> to the pod
Sounds good.
> - We may wonder if it should return undef after all, and how to use
> error() then?
Well, you cannot have it both ways.
When you want parse() to return undef on error you cannot expect the
result to be an object in exactly this case.
Change line 13 to
warn "This is printed" if $schema->error();
and I bet you will get the following output:
Never printed at ./test0.pl line 9.
This is printed at ./test0.pl line 13
> I think it did. The problem now is how to use error().
See above.
Peter
--
Peter Marschall
eMail: [EMAIL PROTECTED]