Re: print statement creates key in hash with reference to empty array??
- From: "rhorizon74" <rhorizon74@xxxxxxxxx>
- Date: 31 Jan 2006 13:43:03 -0800
Hi,
The code i posted is just a sample, i was trying to understand exactly
what was happening.
The are a bunch of scenarios where a different module is supposed to
build a hash, and my module needs to print the values. In which case
for each level of nesting of a hash i will be forced to check if the
node exists (starting with the outer hash and going onto the inner
hash). With my limited exposure to perl i guess it seemed a bit
diffcult to grasp.
I do understand the efficiency it provides while creating a structure.
I did check with a lot of colleagues some who were not exactly novices
like me with way much more experience in perl and they too had come
across this scenario (they grappled with this by adding checks for each
level before printing the values) , but to be honest none with any
exact knowlege of vivication. So it did seem like this problem was
commonly faced by a lot of programmers.
Thanks for the reply
Uri Guttman wrote:
> >>>>> "r" == rhorizon74 <rhorizon74@xxxxxxxxx> writes:
>
> r> Thanks for the help.
> r> That explains what is happening (i had used the exists approach to work
> r> around).
> r> But it does seem bogus that for a simple print statement i need to
> r> check each and every level. I havent seen too many languages do
> r> something like this (i may be wrong).
> r> But a print statement shouldnt really be creating any data.
>
> if you read my article (which sinan posted the url for) then you will
> learn more about autoviv and why it is like it is. and even calling
> exists will do the same thing (but that is being fixed in perl6). the
> win of autovivication is much greater then the loss of rare code like
> yours. if you didn't have it you would need to check each time you used a
> reference in structure and either assign a new one or use the existing
> one. that is massively ugly and clumsy (and i have seen newbies coding
> like that all the time).
>
> uri
>
> --
> Uri Guttman ------ uri@xxxxxxxxxxxxxxx -------- http://www.stemsystems.com
> --Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
> Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
.
- Follow-Ups:
- Re: print statement creates key in hash with reference to empty array??
- From: Uri Guttman
- Re: print statement creates key in hash with reference to empty array??
- References:
- print statement creates key in hash with reference to empty array??
- From: rhorizon74
- Re: print statement creates key in hash with reference to empty array??
- From: it_says_BALLS_on_your forehead
- Re: print statement creates key in hash with reference to empty array??
- From: rhorizon74
- Re: print statement creates key in hash with reference to empty array??
- From: Uri Guttman
- print statement creates key in hash with reference to empty array??
- Prev by Date: Re: split the sequences
- Next by Date: Re: split the sequences
- Previous by thread: Re: print statement creates key in hash with reference to empty array??
- Next by thread: Re: print statement creates key in hash with reference to empty array??
- Index(es):
Relevant Pages
|