in reply to Re: help on reference to hash
in thread help on reference to hash

Hi Dave,

thanks for your kind reply. I have tried the code, but it seems I have some problem on this piece of code:

my %my_tcldefs = %{$cliParms->{'tclDefs'}};

there is no value passed to %my_tcldefs and %my_tcldefs is empty. Could you please give me more guidance? thanks very much!

Replies are listed 'Best First'.
Re^3: help on reference to hash
by AppleFritter (Vicar) on Jun 21, 2014 at 09:52 UTC

    That's because it should be tcl_defs, not tclDefs:

    my %my_tcldefs = %{$cliParms->{'tcl_defs'}};

    EDIT: for the benefit of later readers and to avoid confusion, when I wrote this reply, the original question (since edited, apparently) indeed said tcl_defs.

      Hi Dave,

      that is not the reason. Original design is tclDefs and I'm sure I matched the name in original reference. I guess there maybe other reasons, but I can't find it. thanks.

        In that case I'm not sure. The following works for me:

        #!/usr/bin/perl use feature qw(say); use Data::Dumper; $cliParms = { 'tcl_defs' => { my_var1 => 'a', my_var2 => 'b' } }; my %my_tcldefs = %{$cliParms->{'tcl_defs'}}; say Dumper(\%my_tcldefs);

        Could you post the code that's currently failing for you?

        P.S. I'm not Dave (davido).