Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
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 (Abbot) 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 lurking in the Monastery: (10)
As of 2014-09-21 11:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (168 votes), past polls