rHOnDO has asked for the wisdom of the Perl Monks concerning the following question:
@myArea = sort (keys %{$camArray{$trafficArea}}); $items = scalar @myArea;
Then, I can use a "for" loop to print out each name ...
for ($i=0; $i < $items; $i++) { print "\t<option>$myArea[$i]\n"; }
but this of course uses the keys sort. So I've been trying to do something along the lines of ...
for ($j=0; $j < $items; $j++) { print "$camArray{$trafficArea}{$j}\n"; }
to get at the values in order, all to no avail. Is there a way to get at the entries in a hash in order? Here is the hash of hashes I'm using ...
%camArray = ( 'seattle' => { ' Select a Traffic Cam' => '', 'I-5 at NE 45th St' => 'cctv135', 'I-5 at Roanoke St' => 'cctv126', 'I-5 at Yesler Way' => 'cctv105', 'I-5/I-90 Interchange' => 'cctv812', 'I-5 at Holgate St' => 'cctv098', 'I-5 at Spokane St' => 'cctv093', 'I-5 at Albro Place' => 'cctv086', 'I-5 at Mid Boeing Field' => 'cctv081', 'I-90 at 18th Ave. S.' => 'cctv821', 'I-90 Midspan' => 'cctv859', 'Hwy 520 at Montlake' => 'cctv504', 'Hwy 520 Midspan' => 'cctv509', 'Hwy 99 at Michigan St' => 'cctv498', 'Hwy 99 at W Marginal Way' => 'cctv497' }, 'tacoma' => { ' Select a Traffic Cam' => '', 'Narrows Bridge - westside' => '016cc0085', 'Narrows Bridge - eastside' => '016cc0047', 'I-5 south of Tacoma' => 'TacSouth', 'I-5 north of Tacoma' => 'TacNorth', 'I-5/Hwy 16 Interchange' => '005cc1324', 'I-5 at S. 48th Street' => '005cc1312', 'Hwy 16 at Center St.' => '016cc0019', 'Hwy 16 at Pearl St.' => '016cc0037' }, );
Thanks for any help!
rHOnDO
Originally posted as a Categorized Question.
|
|---|