in reply to Re: Shift returning pointer
in thread Shift returning pointer

Thanks guys, that makes sense to a degree. I'm not sure why it changes to array refs though. Here is my code where I am assigning what is in the list.

open(ENVIRONMENTS, "environments.txt"); while(<ENVIRONMENTS>){ my $line = $_; chomp($line); push @{$Envs->{data}}, [$line];

Replies are listed 'Best First'.
Re^3: Shift returning pointer
by bellaire (Hermit) on Mar 16, 2009 at 18:11 UTC
    The square brackets around $line put it into an array ref before pushing it onto @{$Envs->{data}}. Drop them, and it'll work the way you want:
    push @{$Envs->{data}}, $line;

      Okay, I figured out where my problem is. here it is.

      push @{$EnvsToRun->{data}}, [$environment, $duration, $config];

      When I try to add it to a list with 3 columns, I get the array ref, but if I take the square brackets off, I get three separate entries, with the variable argument in the first column of each entry with they other two as 0s. If I use the brackets, I get the array ref, and then the other two columns are fine. I've tried a few combos of parantheses and brackets, but the brackets seem to be the only things that matter.

        You're confusing me. Once again, you're showing me half of your code (the assignment part this time), and not the part where you are getting the values out. This is new code, and I'm a little frustrated that you say you've found the problem, and it's in code you never showed us. Are you trying to say that $environment is an array ref, but otherwise your code works fine? That's what my previous reply was attempting to fix. I didn't mean for you to take away all brackets everywhere, especially considering I've never seen this line of code before. Would you care to post a more complete code sample?