in reply to Re: Stuck on a Perl assignment
in thread Stuck on a Perl assignment

I am still struggling with this code .. i cant figure out much after going through documentation ... this method works whats the error in this ..
#!/usr/bin/perl use strict; use warnings 'all'; my $structure = [ { a => 1, b => 2, c => 3 }, { d => 4, e => 5 +}, [ 6, 7, 8 ], 9, 10, 11, [ 12, 13, 14 ] ]; sub addtwo { my $params = shift; my $s = $params->{$structure}; if (ref($s) eq "ARRAY") { my $c = 0; foreach my $e (@{$s}) { $s->[$c] = addtwo({ structur => $e }); $c++; } } elsif (ref($s) eq "HASH") { if (scalar keys %{$s} == 0) { return undef; } else { foreach my $e (values %{$s}) { $s->{$e} = addtwo({ structure => $s->{$e} }); } } } else { $s = 1; } return my $c; }

Replies are listed 'Best First'.
Re^3: Stuck on a Perl assignment
by choroba (Cardinal) on Feb 07, 2017 at 08:48 UTC
    A hash key is always a string. What do you the following does when $structure is an array reference?
    my $s = $params->{$structure};

    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
Re^3: Stuck on a Perl assignment
by Anonymous Monk on Feb 06, 2017 at 20:58 UTC
    What is the error message?