Hello!

  I want to make do a nested hash structure, which seems like that:

  my  $pname   =  $self->{db}->{product}->offers->{   $product_id}  ->
{name};

This kind of structures can be easily created by TableMap.

Problem: If any  of the hash keys are undef, then  perl "die"-ing with
an error: Cannot use undef as a HASH reference...

I suggest  two kind of solution  in the new (perl6)  language, because
I think perl5 don't have good solution for that:

1, $__ variable, which is the result of the last operation, e.g:

my $pname  = $self->{db}  && $__->{product}  && $__->offers  && $__->{
$product_id } && $__->{name}

2, &&$ operator, which can be used like that:

my  $pname  =  $self->{db  &&$  ->{product}  &&$  ->offers  &&$  ->  {
$product_id } &&$ ->{name};

I  suggest the  second, because  it is  more straightforward,  but the
first is more flexible.

Regards,

dLux
--
Linux is like wigwam: no windows, no gates, apache inside!

Reply via email to