looping over an array of hashes
- From: iamnotregistered@xxxxxxxxxxx (Graeme McLaren)
- Date: Fri, 28 Apr 2006 15:40:43 +0100
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 :)
.
- Follow-Ups:
- Re: looping over an array of hashes
- From: DJ Stunks
- Re: looping over an array of hashes
- From: Mr. Shawn H. Corey
- Re: looping over an array of hashes
- Prev by Date: Re: General Perl/Web questions
- Next by Date: Replying to the perl list (was Re: problem with whitespace not splitting on split.)
- Previous by thread: General Perl/Web questions
- Next by thread: Re: looping over an array of hashes
- Index(es):
Relevant Pages
|
|