[prev in list] [next in list] [prev in thread] [next in thread] 

List:       perl-win32-users
Subject:    RE: How to push a hash on to a hash of array entries
From:       Ken Cornetet <Ken.Cornetet () kimball ! com>
Date:       2011-11-08 19:14:53
Message-ID: DF6A68E27C9C734592018E2317E9583607115716DE () nts532 ! kii ! kimball ! com
[Download RAW message or body]

I usually find that when I start getting data structures so complicated that I have \
to think about it, it is time to move to objects. Using objects usually makes the \
complicated data structures go away.

Ken Cornetet 812.482.8499
To err is human - to moo, bovine.

-----Original Message-----
From: perl-win32-users-bounces@listserv.ActiveState.com \
                [mailto:perl-win32-users-bounces@listserv.ActiveState.com] On Behalf \
                Of Gabor Szabo
Sent: Tuesday, November 08, 2011 1:06 PM
To: Paul Rousseau
Cc: perl Win32-users
Subject: Re: How to push a hash on to a hash of array entries

On Tue, Nov 8, 2011 at 7:47 PM, Paul Rousseau <paulrousseau277@hotmail.com> wrote:
> I am getting closer, Gabor.

I am glad to hear that :)

> 
> I had the wrong index. These two lines
> 
> push @{$project{$projectno}}, \%days;
> print Dumper %{$project{$projectno}[3]};

I think it is better to always give a reference as a parameter to Dumper (put the \
back-slash in front of the %)

> Now to get at the description within the %days hash. This next line 
> prints a count of the array pointed at by the '3' key.
> 
> print "test 1 " . @{${$project{$projectno}[3]}{"3"}};
> 
> prints "test 1 2"
> 

It looks too complex to me. I wonder if you could change the strategy and work with \
smaller structure. That will be easier to comprehend. Leaving spaces inside the \
brackets can also help. It also seems you have an extra, unnecessary pair of curly \
braces:

This might be slightly more readable:

@{ $project{ $projectno }[3]{3} }

regards
   Gabor
   Perl Tutorial
   http://szabgab.com/perl_tutorial.html
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic