Try this : my @k =keys $cmd_param_show; print "$k[0]\n";

On Thu, Jun 18, 2015 at 3:04 PM, Andrew Solomon <and...@geekuni.com> wrote:

> I'm having trouble understanding your question Sunita. Maybe if you say:
>
> ==
> I want to write a subroutine "helpme" which takes two arguments
> a hashref and a string. Calling
>
> helpme($cmd_param_show, $some_string)
>
> would return
>
> $some_other_string
> ==
> and explain what $some_string and $some_other_string are, I'd be able to
> provide a solution! :)
>
> Andrew
>
>
> On Thu, Jun 18, 2015 at 10:26 AM, Sunita Pradhan <
> sunita.pradhan.2...@hotmail.com> wrote:
>
>> Yeah I am able to access the value but how to get the key ?
>>
>> -Sunita
>>
>> ------------------------------
>> From: akshaymohit2...@gmail.com
>> Date: Thu, 18 Jun 2015 14:46:10 +0530
>> Subject: Re: want to access single value in a hash
>> To: sunita.pradhan.2...@hotmail.com
>> CC: beginners@perl.org
>>
>>
>> Try this:-
>> print
>> "$cmd_param_show->{'scsitrace_start_log_to_disk_true'}->{'param_val'}->{'log-to-disk'}\n";
>>
>> -Akshay
>>
>> On Thu, Jun 18, 2015 at 2:35 PM, Sunita Pradhan <
>> sunita.pradhan.2...@hotmail.com> wrote:
>>
>> I have following data structure :
>>
>> my $cmd_param_show = {'scsitrace_start_log_to_disk_true' =>
>>                          {'param_val'=>{'log-to-disk' => 'true'},
>>                           'scsitrace_show' => {'log-to-disk'    => 'true',
>>                                             'enabled'        => 'true',
>>                                             'max-chain-size' => 16,
>>                                             'max-file-size'  => 0}},
>>                   'scsitrace_stop' =>
>>                    {'param_val'=>{},
>>                     'scsitrace_show' => {'log-to-disk'    => 'false',
>>                                             'enabled'        => 'false',
>>                                             'max-chain-size' => 16,
>>                                             'max-file-size'  => 0}},
>>                    'scsitrace_start' =>
>>                     {'param_val'=>{},
>>                      'scsitrace_show'  => {'log-to-disk'    => 'false',
>>                                             'enabled'        => 'true',
>>                                             'max-chain-size' => 16,
>>                                             'max-file-size'  => 0}},
>>                    'scsitrace_dump' =>
>>                      {'param_val'=>{},
>>                       'scsitrace_show' => {'log-to-disk'    => 'false',
>>                                             'enabled'        => 'false',
>>                                             'max-chain-size' => 16,
>>                                             'max-file-size'  => 0}},
>>                                            };
>>
>> How can I access single value from this hash without using loop ?
>>
>> I tried to print like :
>> print
>> "%{$cmd_param_show}->{'scsitrace_start_log_to_disk_true'}->{'param_val'}\n";
>>
>> It failed .
>> Please help me to get this.
>>
>> Thanks
>> Sunita
>>
>>
>>
>
>
> --
> Andrew Solomon
>
> Mentor@Geekuni http://geekuni.com/
> http://www.linkedin.com/in/asolomon
>

Reply via email to