Rodster001 has asked for the wisdom of the Perl Monks concerning the following question:
Given the following:
Is there a clean (simple) way of adding an additional hash element (i.e. 'flag' => 1) to the array where "url" eq "/html/about.html" without having to itterate though the entire data structure? I've done it with nested foreach/while loops but I imagine this can be done much nicer with map, but I haven't had any success.my $pages; push (@{$pages}, { 'name' => 'Home', 'url' => '/' }); push (@{$pages}, { 'name' => 'About', 'url' => '/html/about.html' }); push (@{$pages}, { 'name' => 'Location', 'url' => '/html/loc.html' });
Thanks!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Clean way of adding values to complex data structure
by blokhead (Monsignor) on Jul 22, 2009 at 21:00 UTC | |
by Rodster001 (Pilgrim) on Jul 22, 2009 at 21:13 UTC | |
Re: Clean way of adding values to complex data structure
by ikegami (Patriarch) on Jul 22, 2009 at 21:09 UTC |
Back to
Seekers of Perl Wisdom