David Gilden wrote:


my (%bags_ordered,$bag); # is it ok to mix match the type of variables inside a # my vars declaration?



Does Perl tell you it isn't? Only thing to watch out for here is combining list and scalar type variables during assignment.


@bags = param('handbag'); #CGI.pm
####
foreach my $bag (@bags){
$bags_ordered{$bag} = {} unless exists $bags_ordered{$bag}; }
####


### Is the code below -- more better and or correct?

foreach my $bag (@bags){
$bags_ordered{$bag} = $bag unless exists $bags_ordered{$bag} }



Well 'better and correct' depends on what your design says, we cannot tell that. They are doing different things, that I can tell you for sure. So the question becomes, do you want to assign an empty anonymous hash (hash ref) in the case that the key doesn't exist, or do you want to assign the same value to the key in that case?


http://danconia.org



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to