>>>>> "R" == Ruud <rvtol+use...@isolution.nl> writes:
R> On 2011-06-03 17:37, sono...@fannullone.us wrote: >> Maybe it's too early in the morning here, but I can't seem to remember how to use a lexical $variable that is defined inside a foreach loop, outside of that loop. =:\ >> >> Here's the loop: >> >> foreach my $name (split (/, */, $names)) { >> next unless ($name =~ /\w/); >> my $sortstr = substr("00$totalcells", -2); >> $html =~ s|</td><td|</td>\n<td|g; >> $cell{"$sortstr$name"} = "<!--//CELL $name//-->"; >> $cell{"$sortstr$name"} =~ s/\[NAME\]/$name/sig; >> $totalcells++; >> } >> >> I want to use "$name" in another loop just after this one, but when I do, I get "Global symbol $name requires explicit package". >> >> Could someone please point me in the right direction? R> What would be the use of that? R> If you declare $name before the loop, it will (after leaving the loop) R> have the last value assigned to it. What would you want that for? not true. see a post i made with a one liner. $name is localized (if not my) so the previous value before the loop is seen after the loop. loop values don't affect the outer $name at all. uri -- Uri Guttman ------ u...@stemsystems.com -------- http://www.sysarch.com -- ----- Perl Code Review , Architecture, Development, Training, Support ------ --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com --------- -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/