Roman Makurin wrote: > On Wed, Jun 24, 2009 at 03:02:00AM +0200, Gunnar Hjalmarsson wrote: >> Roman Makurin wrote: >>> use constant { >>> A => 1, >>> B => 2, >>> C => 3 }; >>> >>> @a = (1, 2, 3); >>> @b = (A, B, C); >>> >>> # first loop >>> while(my $i = shift @a) { >>> print $i, $/ >>> } >>> >>> # second loop >>> while(my $i = shift @b) { >>> print $i, $/ >>> } >>> >>> My question is why the first loop work as expected, but >>> second doesnt. >> My questions are: How did you expect the second loop to work, and what >> output did you get? (They both "worked" fine for me.)
> output of first loop: > 1 > 2 > 3 > > but there is nothing from the second loop, while I expect that it > would be the same. And I dont understand why it happen :) You are missing something. Do you have at the top of your program?: use warnings; use strict; You need to provide more context. Using your exact code above (after adding strict/warnings) I only had to make a couple of simple scoping modifications, and then my output was: pearl# ./constant.pl 1 2 3 1 2 3 Steve
smime.p7s
Description: S/MIME Cryptographic Signature