Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Scalar in structure field name

by dpath2o (Acolyte)
on Sep 30, 2013 at 01:21 UTC ( #1056266=perlquestion: print w/ replies, xml ) Need Help??
dpath2o has asked for the wisdom of the Perl Monks concerning the following question:

Dear Perl Monks, I hope a quick question; I had a hard time finding any leads here or here, so I've come here! My problem is that I have a YAML configuration file:

. . . stations : [ ... , ghed, lanc, ... ] . . . ghed : table_type : lluv rdl9 pattern_type : measured lanc : table_type : lluv rdl8 pattern_type : ideal . . .

I read this file in just fine with:

my $params = HFR::SeaSonde::FileOps->new_operation();

which calls the package that, for the purpose of this query, does this:

my $config_file = exists $args{config_file} ? $args{config_file} : +$ENV{"HOME"}.'/acorn_perl.yml'; $self = LoadFile $config_file;

and returning back to the calling script:

my @stations = @{$params->{codenames}->{codar_stations}};

My PROBLEM is this:

foreach my $station (@stations) { my $table_type = $params->{local}->{$station}->{realtime}->{tabl +e_type}; print $table_type."\n"; } exit;

which prints nothing and exits. I know my problem is $station as a 'field name'. Is there a solution to this?

Comment on Scalar in structure field name
Select or Download Code
Re: Scalar in structure field name (ddumper)
by Anonymous Monk on Sep 30, 2013 at 02:13 UTC

      Jeez! I'm a silly bugger! Sorry for the waste of time here as the problem was completely foolish ...
      here's what I was doing:

      my $table_type = $params->{local}->{$station}->{realtime}->{table_type +};

      and here's what I should be doing:

      my $table_type = $params->{local}->{realtime}->{$station}->{table_type};

      I'll go sit in the corner now with my cap of shame on ...

        To save you some finger strain in the future: all of those ->s beyond the first one are not required.

        my $table_type = $params->{local}{realtime}{$station}{table_type}; Will do the same thing.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1056266]
Approved by mtmcc
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2014-09-23 22:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (241 votes), past polls