in reply to Problem with array references

Well your first problem is that you need to use quotes to wrap the items in your array.

The second issue is that you are using symbolic references to get an array ref. That is to say you are looking up the reference points to the name of the array rather than a direct link to the array.

Is there any reason you can't push onto a plain old array or a dereferenced hard reference?

Here is an example with a hard reference;

use strict; my @test=qw(test trial good); my $testref=\@test; push @$test, "Testing";


vroom | Tim Vroom | vroom@blockstackers.com

Replies are listed 'Best First'.
Re: Re: Problem with array references
by Stamp_Guy (Monk) on Sep 25, 2001 at 07:52 UTC
    Yea, there are a few reasons. I posted a test case up there. Here is real code:
    push @$month, { DATES => $dates, CITY => $city, STATE => $state, TITLE => $title, LOCATION => $location, }
    The $month variable contains the name of the month. The data needs to be put in the appropriate array based on what the month variable contains. I could just make a giant if/then loop and do it, but I was looking for something shorter...
        Yup, that's what I ended up doing. Thanks for the suggestions!