Any Perl victims care to explain this?

Jeremy jepri at
Thu Apr 4 20:42:51 EST 2002

On 2002.04.04 20:28 Matthew Hawkins wrote:
> On Thu, 04 Apr 2002, Martijn van Oosterhout wrote:
> > It's not random. If you only put integers in, you only get integers
> out. I
> > don't understand your problem.
> I'm not putting anything in.  The hash is tied to a pre-populated
> db table, the particular field being looked at is of type INTEGER, and
> each row has a number in it.  I think that qualifies as being an
> integer, and does little to explain this particular instance of Perl's
> inconsistencies.
> [...]
> > I think you are confused.
> Think *I'm* confused?  When I print the ref() of the two values I'm
> getting back (I have two hash references to two different tables), one
> is returning an ARRAY (today, yesterday it was returning ARRAYREF and
> the only thing I've done in-between is eat & sleep), the other is
> returning a nothing.
> That's right, a nothing.  ref() is blank.  It's not a SCALAR, REF,
> ARRAY, HASH, CODE or GLOB as the Perl documentation states ref
> returns.

That means it is the other option, UNDEF.  Undef is fairly close to a 

> Yesterday, it was a SCALAR, and an ARRAYREF, depending on the number
> of
> black taxis circling the tower of london or whatever, at the exact
> time
> I launched the script.  Oh, the MySQL db is static - its not changes
> there affecting the script as nothing is being altered in any way.
> I don't think I'm the confused one.  I think that last one is funny
> because its so random even the Perl interpreter doesn't know what the
> hell it is! :-)  I can take a wild stab in the dark at guessing it's
> scalar, since print will print it correctly (and being a good boy I've

Nope.  Perl *always* knows what it's variables are.  Your database call 
is probably failing somewhere.  Try checking the return values of your 

> got strict on so print bitches if I try giving it non-scalar things).

Nup.  Print will cheerfully print anything.

> But ref() doesn't think so, the SCALAR check in the superbuttugly
> conditional block is never entered, and the script dies in my
> catch-all
> clause with "Perl sucks" :-)
> The only reason I did this in Perl in the first place was because DBI
> and associates, plus the integrated regexping, are hard to match in
> other languages - and they're what I need to do. :(
> I don't actually need any help (I'm going to redo the whole script in
> something that can be trusted, which I should have done in the first
> place with 20/20 hindsight), just BED (bitching et demonstratum?) that
> $value = $table->{'key'};
> is yet another Perl construct that is consistently inconsistent.
> --
> Matt

More information about the linux mailing list