in reply to Not an ARRAY reference, even though it is?

Do you have use warnings; at the top of your program? It appears not, as this code:

[nick:~/monks]$ perl -Mstrict -Mwarnings -e" my @foo; push @foo = {bar=>'baz'}; "
produces this output for me:
Useless use of push with no values at -e line 2. push on reference is experimental at -e line 2. Not an ARRAY reference at -e line 2.
As you can see the first line of the output is more descriptive about the error, which often helps you find it more quickly. So always use warnings;.

As an aside: You don't show what you do with your array, but I am wondering if it might not be more useful for you to have your invoices stored in a hash so you can retrieve them by index:

#! perl use strict; use warnings; my $cast = list_characters()->{'cast'}; print "The Human is $cast->{'Human'}->{'fname'} $cast->{'Human'}->{'ln +ame'}."; print " He is always displaying $cast->{'Human'}->{'characteristic'}.\ +n"; sub list_characters { my $Guide; $Guide->{'cast'}->{'Human'} = { fname => 'Arthur', lname => 'Dent', characteristic => 'bewilderment', }; $Guide->{'cast'}->{'Betelgeusian'} = { fname => 'Zaphod', lname => 'Beeblebrox', characteristic => 'narcissism', }; $Guide->{'cast'}->{'Robot'} = { fname => 'Marvin', lname => 'the Paranoid Android', characteristic => 'depression', }; return $Guide; } __END__

Output:

[09:07][nick:~/monks]$ perl 1139851.pl The Human is Arthur Dent. He is always displaying bewilderment.

The way forward always starts with a minimal test.

Replies are listed 'Best First'.
Re^2: Not an ARRAY reference, even though it is?
by ultranerds (Hermit) on Aug 25, 2015 at 17:09 UTC
    Thanks - yeah I have strict and warnings enabled :)

    For the code - thats how I ended up doing it. I only put it into a new var after having the issue with the "not an ARRAY" issue. After I got that figured out, I moved it all back into the main hash (along with all the order details)

    Thanks!