Re: question about constants

2009-06-24 Thread Jenda Krynicky
Steve Bertrand wrote: > Roman Makurin wrote: > > On Wed, Jun 24, 2009 at 03:25:57PM +0200, Jenda Krynicky wrote: > >> From: Roman Makurin > >>> here is complite perl script which produces such results without > >>> any warning: > >>> > >>> #!/usr/bin/perl > >>> > >>> use strict; > >>> use warning

Re: question about constants

2009-06-24 Thread Steve Bertrand
Roman Makurin wrote: > On Wed, Jun 24, 2009 at 03:25:57PM +0200, Jenda Krynicky wrote: >> From: Roman Makurin >>> here is complite perl script which produces such results without >>> any warning: >>> >>> #!/usr/bin/perl >>> >>> use strict; >>> use warnings; >>> >>> use constant { >>> A => 0, >

Re: question about constants

2009-06-24 Thread John W. Krahn
Jenda Krynicky wrote: But of course this does not print anything. The shift(@a) returns the first element of @a which is zero, assigns that to $i and then checks whether it's true. And of course it's not. So it skips the body and leaves the loop. Keep in mind that the value of my $i = sh

Re: question about constants

2009-06-24 Thread Roman Makurin
On Wed, Jun 24, 2009 at 03:25:57PM +0200, Jenda Krynicky wrote: > From: Roman Makurin > > here is complite perl script which produces such results without > > any warning: > > > > #!/usr/bin/perl > > > > use strict; > > use warnings; > > > > use constant { > > A => 0, > > B => 1, > >

Re: question about constants

2009-06-24 Thread Gunnar Hjalmarsson
Steve Bertrand wrote: Roman Makurin wrote: On Wed, Jun 24, 2009 at 04:37:52AM +0200, Gunnar Hjalmarsson wrote: 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 hi

Re: question about constants

2009-06-24 Thread Jenda Krynicky
From: Roman Makurin > here is complite perl script which produces such results without > any warning: > > #!/usr/bin/perl > > use strict; > use warnings; > > use constant { > A => 0, > B => 1, > C => 2 }; > > my @a = (A, B, C); > my @b = (1, 2, 3); > > while(my $i = shift @a

Re: question about constants

2009-06-24 Thread Steve Bertrand
Roman Makurin wrote: > On Wed, Jun 24, 2009 at 04:37:52AM +0200, Gunnar Hjalmarsson wrote: >> 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 hin

Re: question about constants

2009-06-24 Thread Roman Makurin
On Wed, Jun 24, 2009 at 04:37:52AM +0200, Gunnar Hjalmarsson wrote: > 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. > here is complite perl scri

Re: question about constants

2009-06-23 Thread Gunnar Hjalmarsson
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

Re: question about constants

2009-06-23 Thread Steve Bertrand
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, $/

Re: question about constants

2009-06-23 Thread Roman Makurin
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 >>

Re: question about constants

2009-06-23 Thread Gunnar Hjalmarsson
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 expecte

question about constants

2009-06-23 Thread Roman Makurin
Hi All today i spend a lot of time with following problem. part of code: 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, $/