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 :)
Strange.
It looks like strictures and warnings are not enabled (@a and @b are not
declared). Try to add
use strict;
use warnings;
and see if that makes Perl give you a hint.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/