in reply to Recover a path from a config file

Hey monks !

I request your wisdom last time for this subjet. I would prefer to post it here than to edit it in a new post.

I would like to get value below :

name => 'VIKTOR ',

And i did that :

my $firstName = $config->{name};

And i tried following code too but it doesn't work too:

my $firstName = ${$config->{programs}}[0];

It doesn't work . I would like to understand. Did i forget something?

Thanks !!

*****Lost in translation****TIMTOWTOI****Scribe !yes!***

Replies are listed 'Best First'.
Re^2: Recover a path from a config file
by hippo (Archbishop) on Jun 07, 2016 at 13:55 UTC
    It doesn't work . I would like to understand. Did i forget something?

    Just these:

    • A detailed specification of the way in which it "doesn't work"
    • The precise, full text of the error message you received
    • An SSCCE demonstrating the problem in a reproducible manner

    Without these the problem could simply be a typo in your code and nobody would ever know. Help others to help you.

      Yes . Much for me. I forgot output:

      When i do :

      my $firstName = $config->{name};

      I get the following output :

      Use of uninitialized value $firstName in print atline 115.

      And when i do that :

      my $firstName = ${$config->{programs}}[1];

      i get output below :

      HASH(0x3e25178)

      If i do :

      my $firstName = ${$config->{programs}}[0];

      i obtain in my output:

      VIKTOR DESCRIPTION PRODUCT
      *****Lost in translation****TIMTOWTOI****

        Well, that's a start for sure. Since you still haven't provided an SSCCE, here's one:

        #!/usr/bin/env perl use strict; use warnings; my $config = { programs => [ 'VIKTOR DESCRIPTION PRODUCT' => { name => 'VIKTOR ', parameters => [ Count_id => '06 (Viktor)', ] } ] }; print $config->{programs}->[1]->{name} . "\n";

        IMHO that config file is a mess. Running it with a do or an eval is dangerous as others have mentioned and its structure is arcane at best. I hope for your sake that it's all some big XY problem and the actual task can be solved in an entirely different manner.