Dr.Ruud wrote: > H.Merijn Brand wrote: >> Michael G Schwern: >>> What I was thinking was something like: >>> >>> open my $fh, "<", $file or die $fh->error; >> >> this is *very* counter-intuitive. >> After a fail, I expect $fh to be false. How do I call a method on an >> undefined value? > > Welcome to the wonderful world of objects. Though defined() is tougher: perl -Mstrict -MData::Dumper -wle' my $value; # undef my $obj = bless \$value, "Foo"; print Dumper $obj; print "defined:", defined $obj; print $obj; package Foo; use overload nomethod => \&_val; sub _val { ${ $_[0] } } ' $VAR1 = bless( do{\(my $o = undef)}, 'Foo' ); defined:1 Use of uninitialized value in print at -e line 9. Can "//" obey overloading? -- RuudThread Previous