[CDBI] Updating data automatically after a search (trigger)

Bill Moseley moseley at hank.org
Wed Feb 1 19:54:40 GMT 2006


On Wed, Feb 01, 2006 at 02:35:36PM -0500, Perrin Harkins wrote:

use strict;
use warnings;

    foo(1);
    foo(0);
    foo(0);

    sub foo {
        my $arg = shift;
        my $bar = {} if $arg;
        $bar ||= {};
        print "bar: $bar\n";
    }

    bar: HASH(0x814ac28)
    bar: HASH(0x814ada8)
    bar: HASH(0x814ada8)

That's nasty.

So it seems like from perldiag that people have exploited this bug,
and that the warning is to tell them that the behavior will go away
and the bug will be fixed.  So in the future that construct will work.


The bug doesn't show up in a perhaps more common situation:

    use strict;
    use warnings;

    foo(1);
    foo(0);
    foo(0);
    foo(1);

    sub foo {
        my $arg = shift;
        my $bar = 1 if $arg;
        print "bar is ", $bar ? "set\n" : "not set\n";
    }

    bar is set
    bar is not set
    bar is not set
    bar is set






-- 
Bill Moseley
moseley at hank.org





More information about the ClassDBI mailing list