in reply to Re^6: Shift returning pointer
in thread Shift returning pointer
That's not right, you'll get an array ref in $environment. You forgot that @{$EnvsToRun->{data}} holds many inner lists, each of them with 3 elements in it. To get the first one out by itself, you'd do something like this (note the ->[0]):my ($environment, $duration, $config) = @{$EnvsToRun->{data}};
In practice, to deal with all of the combinations, you need to iterate over the outer array and then for each item there process the inner array. Like this:my ($environment, $duration, $config) = @{$EnvsToRun->{data}->[0]};
If you don't want many inner lists, but just the one, you shouldn't be using push at all when assigning to $EnvsToRun->{data}. Instead, a simple assignment:for my $CurrentEnv (@{$EnvsToRun->{data}}) { my ($environment, $duration, $config) = @$CurrentEnv; ... }
$EnvsToRun->{data} = [$environment, $duration, $config]; ... later ... ($environment, $duration, $config) = @{$EnvsToRun->{data}};
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: Shift returning pointer
by rgb96 (Acolyte) on Mar 16, 2009 at 19:40 UTC | |
by bellaire (Hermit) on Mar 16, 2009 at 19:51 UTC | |
by rgb96 (Acolyte) on Mar 16, 2009 at 20:34 UTC |