RE: Looping through a Hash

2003-01-09 Thread Timothy Johnson
\n"; } -Original Message- From: Wiggins d'Anconia [mailto:[EMAIL PROTECTED]] Sent: Wednesday, January 08, 2003 4:32 PM To: Johnstone, Colin Cc: '[EMAIL PROTECTED]' Subject: Re: Looping through a Hash Sort of foreach my $key (keys(%picDetails)) { my $val = $picDetails

Re: Looping through a Hash

2003-01-09 Thread Rob Dixon
Hi Colin This does what you want: while (($k, $v) = each %picDetails ) { # do stuff to $v; } Note that to modify the hash's copy of $v you would have to change $picDetails{$k}. HTH, Rob "Colin Johnstone" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL

Re: Looping through a Hash

2003-01-08 Thread Wiggins d'Anconia
Sort of foreach my $key (keys(%picDetails)) { my $val = $picDetails{$key}; # do stuff to val } or while (my ($key, $val) = each (%picDetails)) { # do stuff to key or val } (foreach may work here as well, but I have always preferred while's for some reason) perldoc -f each perldoc -f