On Tue, May 27, 2003 at 07:24:24PM +0000, Ton Hospel wrote:
> In article <[EMAIL PROTECTED]>,
>       [EMAIL PROTECTED] (Ton Hospel) writes:
> 
> Notice by the way you can actually see what's happening like this:
> 
> perl -MO=Deparse -wle 'sub fun { print $_++ for reverse 1..3} BEGIN { fun}; fun'
> 3
> 2
> 1
> BEGIN { $^W = 1; }
> BEGIN { $/ = "\n"; $\ = "\n"; }
> sub fun {
>     foreach $_ (reverse +(2, 3, 4)) {
>         print $_++;
>     }
> }
> sub BEGIN {
>     fun ;
> }
> fun ;


And this shows the behaviour is a bug. Running

   $ perl -wle 'sub fun { print $_++ for reverse 1..3} BEGIN { fun}; fun'

gives:

   3
   2
   1
   4
   3
   2


But the code generated by Deparse doesn't compile; when the BEGIN is
executed, it dies with "Modification of a read-only value attempted".

"1 .. 3" should behave the same as "1, 2, 3", but it turns out it doesn't.


Abigail

Reply via email to