develooper Front page | perl.perl5.porters | Postings from August 2001

Re: Backwards compatibility breakage in foreach?

Thread Previous | Thread Next
From:
Graham Barr
Date:
August 21, 2001 11:05
Subject:
Re: Backwards compatibility breakage in foreach?
Message ID:
20010821190436.E7667@pobox.com
You will find the answer to your question in perldelta.pod for 5.6.0

  =head2 Improved C<qw//> operator

  The C<qw//> operator is now evaluated at compile time into a true list
  instead of being replaced with a run time call to C<split()>.  This
  removes the confusing misbehaviour of C<qw//> in scalar context, which
  had inherited that behaviour from split().

  Thus:

      $foo = ($bar) = qw(a b c); print "$foo|$bar\n";

  now correctly prints "3|a", instead of "2|a".

This change meant that the list created by qw() is now a list of
constants.

Graham.


On Tue, Aug 21, 2001 at 01:55:50PM -0400, Michael G Schwern wrote:
>     foreach my $thing (qw(foo bar)) { 
>         $thing = 'something else';
>     }
> 
> This innocent looking loop runs fine in 5.004_05 and 5.005_03.  Run it
> in 5.6.1 or bleadperl and you get:
> 
>     Modification of a read-only value attempted
> 
> Smells like backwards compatibility breakage to me.
> 
> 
> -- 
> 
> Michael G. Schwern   <schwern@pobox.com>    http://www.pobox.com/~schwern/
> Perl6 Quality Assurance     <perl-qa@perl.org>	     Kwalitee Is Job One
> "Let's face it," said bearded Rusty Simmons, opening a can after the
> race.  "This is a good excuse to drink some beer."  At 10:30 in the
> morning?  "Well, it's past noon in Dublin," said teammate Mike
> [Joseph] Schwern.  "It's our duty."
>     -- "Sure, and It's a Great Day for Irish Runners" 
>        Newsday, Sunday, March 20, 1988

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About