--- Kyle Babich <[EMAIL PROTECTED]> wrote:
> Ok, I've got it down to one problem right now, I need an explicit 
> package name for this:
> foreach $key(keys %pages) {
>       print "<a href=\"$pages{$key}\">$key</a>\n";
> }
> 
> It says I need it for $key but no matter where I put the my it won't 
> stop giving me that error.  Where in that does the my go?

  foreach my $key ( keys %pages ) {
    # do stuff
  }

However, when I need both the key and the value from the hash, I prefer to use the 
"each" iterator
with a while loop:

  while ( my ($key, $value) = each %pages ) {
    print qq{<a href="$value">$key</a>}\n};
  }

Cheers,
Curtis "Ovid" Poe

=====
"Ovid" on http://www.perlmonks.org/
Someone asked me how to count to 10 in Perl:
push@A,$_ for reverse q.e...q.n.;for(@A){$_=unpack(q|c|,$_);@a=split//;
shift@a;shift@a if $a[$[]eq$[;$_=join q||,@a};print $_,$/for reverse @A

__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to