[Israel.pm] exists/defined problem :-(

Gaal Yahas gaal at forum2.org
Sun Sep 11 07:10:55 PDT 2011


In Perl, once you say $a->{$b}->{$c}, $a->{$b} will "spring into
existence". From perlref:

           The left side of the arrow can be any expression returning a
reference, including a
           previous dereference.  Note that $array[$x] is not the same thing
as "$array->[$x]"
           here:

               $array[$x]->{"foo"}->[0] = "January";

           This is one of the cases we mentioned earlier in which references
could spring into
           existence when in an lvalue context.  Before this statement,
$array[$x] may have been
           undefined.  If so, it's automatically defined with a hash
reference so that we can look
           up "{"foo"}" in it.  Likewise "$array[$x]->{"foo"}" will
automatically get defined with
           an array reference so that we can look up "[0]" in it.  This
process is called
           autovivification.


On Sun, Sep 11, 2011 at 4:24 PM, Chanan Berler <bc.other at gmail.com> wrote:

> Hello All,
>
>        # check if result key GetUmsPlayerData found
>        if (
> exists($result->{'response'}->{'Player'}->{'GetUmsPlayerData'}->{'player_data'})
> )
>        {
> #
> $result->{'response'}->{'Player'}->{'GetUmsPlayerData'}->{'player_data'}
> = $self->_player_data_by_key_to_name_($result->{'response'}->{'Player'});
>        }
>
> Funny after adding this condition (see no action is done - comments)
> and printing using Data::Dumper i found this:
>
> Sep 11 13:18:17 dev-host-03.playtechtv.tv: [pid:26150] [debug]
> [mixtv::payment::PlaytechUMS_base::_PARSE_RESPONSE_] response returned
> with error (0). system-error-code was set to 100.
> Sep 11 13:18:17 dev-host-03.playtechtv.tv: [pid:26150] [debug]
> [mixtv::payment::PlaytechUMS_base::_simple_trace_] =========>
> params=$VAR1 = { 'req_ref' => '7864384', 'req_name' => 'LOGIN', 'data'
> => { 'Player' => { 'errorText' => '', 'errorCode' => '0',
> 'GetUmsPlayerData' => {}, 'Login' => { 'sessionToken' =>
> '1DC46A42BAFD44A4714F6C33FBBA84CE', 'sessionValidationData' => undef,
> 'errorText' => '', 'errorCode' => '0', 'playerCode' => '2752191',
> 'phone' => undef, 'username' => 'MBTEST10' } } }, 'type' => 'RESPONSE'
> };
>
> Notice GetUmsPlayerData was added to my Hash ?? is this a memory
> problem with exists ? checking same thing using defined i found same
> problem :-(
>
> -Chanan
>
>
> --
> ===================
> ----     Chanan Berler    ----
> ===================
> _______________________________________________
> Perl mailing list
> Perl at perl.org.il
> http://mail.perl.org.il/mailman/listinfo/perl




-- 
Gaal Yahas <gaal at forum2.org>
http://gaal.livejournal.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.perl.org.il/pipermail/perl/attachments/20110911/7c866b4b/attachment-0001.htm 


More information about the Perl mailing list