Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Type of arg 1 to push must be array (not private variable)

by natxo (Sexton)
on Aug 25, 2014 at 13:03 UTC ( #1098524=perlquestion: print w/ replies, xml ) Need Help??
natxo has asked for the wisdom of the Perl Monks concerning the following question:

I have this code working on perl 5.18 but when using 5.10 I get the error on the title:

my $data_ref = []; while (<$fh>) { chomp; my %temp = /($keys): (.+)/g; if (/^\s+Description:\s+(.+)\z/sm) { $temp{Description} = $1; } push $data_ref, \%temp; }
Apparently according to this Stackoverflow post http://stackoverflow.com/questions/20824920/perl-array-references-and-avoiding-type-of-arg-1-to-keys-must-be-hash-error this is something new since 5.14.

How can I solve this for 5.10? I cannot upgrade that Perl version just yet. Thanks for your help!

Comment on Type of arg 1 to push must be array (not private variable)
Download Code
Re: Type of arg 1 to push must be array (not private variable)
by choroba (Canon) on Aug 25, 2014 at 13:13 UTC
    Use dereference:
    push @$data_ref, \%temp;
    لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
      so simple ...

      Thanks!

Re: Type of arg 1 to push must be array (not private variable)(splain/diagnostics)
by Anonymous Monk on Aug 25, 2014 at 19:55 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1098524]
Approved by hdb
Front-paged by toolic
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (18)
As of 2015-07-07 14:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (89 votes), past polls