Hofmator has asked for the wisdom of the Perl Monks concerning the following question:
Just the other night I came across the following. Consider
both ways to assign to a hash slice work fine and produce the same results as expected.use strict; use warnings; my %foo; @foo{1..3} = (); print keys %foo; @foo{qw/1 2 3/} = (); print keys %foo;
Now add the following line to it:die "strange .." if foo eq 'bar'; which should make perl barf a "use of bareword 'foo' " error - as we are under strict. But it doesn't!! At least for me. I tried this under Perl 5.6.0 (ActivePerl Build 623) on Windows and Perl 5.6.1 on Linux (2.2.14).
If you remove the first hash slice line (@foo{1..3} = ();) then it works (or better not works i.e. throws the bareword error) correctly.
Well, so my questions are:
-- Hofmator
2002-06-23 Edit by Corion : Changed title
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Strange behaviour (bug?) of use strict 'subs'
by particle (Vicar) on Jun 23, 2002 at 13:32 UTC | |
|
Re: Strange behaviour (bug?) of use strict 'vars'
by ariels (Curate) on Jun 23, 2002 at 12:15 UTC | |
|
Re: Strange behaviour (bug?) of use strict 'vars'
by Anonymous Monk on Jun 23, 2002 at 17:40 UTC | |
by Joost (Canon) on Jun 24, 2002 at 09:43 UTC | |
by Anonymous Monk on Jun 25, 2002 at 03:34 UTC | |
|
Re: Strange behaviour (bug?) of use strict
by little (Curate) on Jun 23, 2002 at 13:15 UTC | |
by Aristotle (Chancellor) on Jun 23, 2002 at 14:00 UTC |