Hi all, I need to loop over an array of hashes and assign a new hashref if a condition is met:

I have a scalar which contains an array of hashes:

$locations = [
         {
           'location_name' => 'Fionas House',
           'location_id' => '9999000000000027'
         },
         {
           'location_name' => 'Central Locations',
           'location_id' => '9999'
         },
         {
           'location_name' => 'The Queen\'s Hoose',
           'location_id' => '1076'
         },
         {
           'location_name' => 'Santa',
           'location_id' => '1075'
         },
]



I want to add an new hash ref in if, for example,

if($x ==9999000000000027){
$locations->[0]->{'location_status'} = 'true'

}


I've been at this a few hours and I'm not getting anywhere, can anyone suggest a way to do this?


Cheers,

G :)



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to