in reply to Re: Looping through an array of hashrefs
in thread Looping through an array of hashrefs

# a simplified approach with less clutter you might find useful.. To me, reducing code I have to maintain 50% makes my job 1/2 as difficult.. You pass in an arrayref you didn't need any returned val I don't think....
sub validate_properties { for ( @{$_[0]} ) { $_->{supported} = 0; $_->{supported}++ if .5 < rand; } }

Replies are listed 'Best First'.
Re^3: Looping through an array of hashrefs
by SuicideJunkie (Vicar) on Sep 24, 2014 at 15:35 UTC

    In that case, why not eliminate half the code in that loop?:

    sub validate_properties { for ( @{$_[0]} ) { $_->{supported} = .5 < rand; } }

    Or even inline it as: $_->{supported} = .5 < rand for @array;?

    Based on the (modified) original post, it should be $_->{supported} = isSupported($_) for @properties; rather than random.
    I don't see how saving the results of an isSupported() test could be described as "validating properties", but I suppose that's a lack of context speaking.

      nice tips thanks I can use that :) Voted u a ++...