in reply to Looping through an array of hashrefs
#!/usr/bin/perl use warnings; use strict; use Data::Dumper; sub validate_properties { my $properties = shift; for my $prop (@{$properties}) { if (.5 < rand) { $prop->{supported} = 1; } else { $prop->{supported} = 0; } } return $properties } print Dumper validate_properties([map +{ id => $_ }, 1 .. 5]);
Output:
$VAR1 = [ { 'id' => 1, 'supported' => 0 }, { 'id' => 2, 'supported' => 0 }, { 'id' => 3, 'supported' => 0 }, { 'id' => 4, 'supported' => 1 }, { 'id' => 5, 'supported' => 0 } ];
So, please show the real code that exhibits the problem.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Looping through an array of hashrefs
by misterperl (Friar) on Sep 24, 2014 at 14:41 UTC | |
by SuicideJunkie (Vicar) on Sep 24, 2014 at 15:35 UTC | |
by misterperl (Friar) on Sep 24, 2014 at 16:04 UTC |