spstansbury has asked for the wisdom of the Perl Monks concerning the following question:
I need to run a script and output some data to be used at a later time. Subsequent running of the script will use the stored data as baseline values to compare against new data.
I'm using Storable:
%base_record has a number of key/value pairs and gets pushed onto @{$baseline} every iteration of the loop. After the loop finishes, I store the AoH's. $baseline_records refers to the data file.push @{$baseline}, \%base_record; store( \$baseline, $baseline_records ) or die "Can't store %a in $base +line_records!\n";
Data::Dumper shows:
$VAR1 = { 'LICount' => 0, 'LICountBase' => 0, 'LIFloat' => 0, 'LIFloatBase' => 0, 'LIICount' => 0, 'LIICountBase' => 0, 'ProjectID' => 'STO1019001', }; $VAR2 = { 'LICount' => 0, 'LICountBase' => 0, 'LIFloat' => 0, 'LIFloatBase' => 0, 'LIICount' => 0, 'LIICountBase' => 0, 'ProjectID' => 'STO1018001', }; $VAR3 = { 'LICount' => 38, 'LICountBase' => 38, 'LIFloat' => 0, 'LIFloatBase' => 0, 'LIICount' => 11, 'LIICountBase' => 11, 'ProjectID' => 'STO1005001', };
When I retrieve the data, I'm getting:
my $arrayref = retrieve( $baseline_records ); print Dumper $arrayref; $VAR1 = \[ { 'LICount' => 0, 'LICountBase' => 0, 'LIFloat' => 0, 'LIFloatBase' => 0, 'LIICount' => 0, 'LIICountBase' => 0, 'ProjectID' => 'STO1019001', }, { 'LICount' => 0, 'LICountBase' => 0, 'LIFloat' => 0, 'LIFloatBase' => 0, 'LIICount' => 0, 'LIICountBase' => 0, 'ProjectID' => 'STO1018001', }, { 'LICount' => 38, 'LICountBase' => 38, 'LIFloat' => 0, 'LIFloatBase' => 0, 'LIICount' => 11, 'LIICountBase' => 11, 'ProjectID' => 'STO1005001', } ];
I know that I'm not dealing with the references properly. The goal is, upon subsequent running of the script, when I loop through the project to return the values based on matching a "ProjectID"
Thanks in advance for any pointers.
Scott...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Storable, reference help needed
by afresh1 (Hermit) on Sep 27, 2010 at 22:28 UTC | |
by spstansbury (Monk) on Sep 28, 2010 at 17:07 UTC |