[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]
Re: Class::Fields, a base/fields.pm rewrite
On Sat, Jan 08, 2000 at 11:04:02PM -0800, Larry Wall wrote:
> Michael G Schwern writes:
> But yours doesn't do what you want either. Note that the following
> always returns 1, not 2:
>
> sub foo { return $x = 1 and 2 }
>
> To get the effect you want, you'd have to say
>
> sub foo { return ($x = 1 and 2) }
D'oh! I see my mistake. I saw
if ($fglob = ${"$base\::"}{"FIELDS"} and *$fglob{HASH}) {
...
}
in base.pm and figured
return $fglob = ${"$class\::"}{"FIELDS"} and *$fglob{HASH};
would work. Cargo-culting strikes again. So @FIELDS = (); will give
a false positive since its only really checking to see if *FIELDS is
around.
> Plus, of course, returning *$fglob{HASH} is never actually going to
> return 1 or 0, but I presume you're really just using those to mean
> true and false.
Yeah. Okay, I'll change it to this:
return ($fglob = ${"$class\::"}{"FIELDS"} and *$fglob{HASH}) ? TRUE
: FALSE;
and add a test to make sure I don't screw this up again.
--
Michael G Schwern schwern@pobox.com
http://www.pobox.com/~schwern
/(?:(?:(1)[.-]?)?\(?(\d{3})\)?[.-]?)?(\d{3})[.-]?(\d{4})(x\d+)?/i
- References to:
-
Michael G Schwern <schwern@pobox.com>
Larry Wall <larry@wall.org>
[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]