Since you arent going to elaborate, I'll just go ahead and refute your claims
DB_File has contained this code longer than perl 5.5 has existed. The situation you describe is nigh impossible (bless would have to fail and return 1, TIEHASH would have to fail and return 1).
15 May 1997 http://search.cpan.org/~chips/perl5.004/
07 May 1997 http://cpansearch.perl.org/src/PMQS/DB_File-1.14/DB_File.pm
sub TIEHASH
{
my $pkg = shift ;
bless { VALID => { map {$_, 1}
qw( bsize ffactor nelem cachesize hash lorder)
},
GOT => {}
}, $pkg ;
}
If you intentionally return 1 , tied would return undef.
#!/usr/bin/perl --
use strict;
use warnings;
Main(@ARGV);
exit(0);
sub Main {
Waha('NewHash');
Waha('OneHash');
}
sub Waha {
my $c = shift;
my $obj = tie my (%foo), $c or die $!;
printf '(%s) $obj=(%s) tied(%%foo)=(%s)' . "\n", $c, $obj,
tied(%foo) || 'undef';
} ## end sub Waha
BEGIN {
package NewHash;
sub TIEHASH {
my $obj = bless {}, shift;
return $obj;
}
package OneHash;
sub TIEHASH { "$_[0] is broken" }
} ## end BEGIN
__END__
(NewHash) $obj=(NewHash=HASH(0x3d8bbc)) tied(%foo)=(NewHash=HASH(0x3d8
+bbc))
(OneHash) $obj=(OneHash is broken) tied(%foo)=(undef)
(NewHash) $obj=(NewHash=HASH(0x225368)) tied(%foo)=(NewHash=HASH(0x225
+368))
(OneHash) $obj=(OneHash is broken) tied(%foo)=(undef)
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|