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!

Replies are listed 'Best First'.
Re: Type of arg 1 to push must be array (not private variable)
by choroba (Cardinal) 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