Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Problem with array references

by vroom (His Eminence)
on Sep 25, 2001 at 07:47 UTC ( [id://114473]=note: print w/replies, xml ) Need Help??


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!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://114473]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2024-04-18 23:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found