Peter Scott wrote:
> $employee{$empno}{SAlARY} -= 10_000; # IPO failure
> $employee{$empno}{FAX} = '888-555-1212';
>
> First one got the wrong key when my finger slipped on the shift key, second
> one got it when I misremembered FAX instead of FACSIMILE. But in neither
> case does Perl point this out. (Yes, I could use objects instead, but
> that's hardly the point.)
>
> I have been unable to come up with a lightweight syntax for saying that the
> second-level hash keys should be fixed. I supplicate the gods of new
> syntax for any succor they may render in my hour of need.
I think RFC 188 addresses this (although it is couched in terms of object
inheritance).
private $employee{$empno}{SAlARY} -= 10_000; # IPO failure
private $employee{$empno}{FAX} = '888-555-1212';
In general, it would be nice to convince DBI to do this for you, when it
creates the hashes, and populates them. But you could simply always do the
call to DBI, then do a
private $employee{$empno}{'!@#$"};
which would add one more key (with a funny spelling unlikely to conflict with
column names) which will turn off the autovivifying for the whole hash as a
side effect.
--
Glenn
=====
Even if you're on the right track,
you'll get run over if you just sit there.
-- Will Rogers
_____NetZero Free Internet Access and Email______
http://www.netzero.net/download/index.html