Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
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

07 May 1997

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)

In reply to Re^4: DB_File modes by Anonymous Monk
in thread DB_File modes by fionbarr

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others drinking their drinks and smoking their pipes about the Monastery: (10)
    As of 2018-10-16 08:32 GMT
    Find Nodes?
      Voting Booth?
      When I need money for a bigger acquisition, I usually ...

      Results (83 votes). Check out past polls.