Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: DB_File modes

by chuckbutler (Priest)
on Feb 11, 2010 at 04:19 UTC ( #822580=note: print w/ replies, xml ) Need Help??


in reply to DB_File modes

If you are using a current version of Perl, say > 5.5, using tie %hash is the way to go. Be advised, on some versions/ports tie DOES NOT return the reference to the underlying object of the tie on success. If you are planning to use an extended routine via $ref->routine( ), you may get the reference by $ref = tied(%hash) first. Be sure that the $ref is undef/out-of-scope before you untie %hash. Good luck. -c


Comment on Re: DB_File modes
Re^2: DB_File modes
by Anonymous Monk on Feb 11, 2010 at 08:44 UTC
    Be advised, on some versions/ports tie DOES NOT return the reference to the underlying object of the tie on success.

    Um, tie always returns the reference to the underlying object, always.

      ...Mostly on non-Unix platforms. You sometimes receive just a 1, true, on success. I have been burned on this a few times, but then again, I work with a lot of non-Unix distributions. Thanks. -c

        That is not a very convincing argument.
        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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://822580]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2014-09-20 06:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (155 votes), past polls