[kw-pm] is perl 6 really that different?

Robert P. J. Day rpjday at mindspring.com
Tue Jul 8 17:58:39 CDT 2003


On Tue, 8 Jul 2003, Andrew Kohlsmith wrote:

> > > I don't have the book, but that's one of perl6 changes- arrays and
> > > hashes retain their sigil when they're sliced/diced.
> 
> > holy crap.  so perl 6 is not even remotely backward compatible?
> > apparently, i have some serious reading to do.  thanks.
> 
> You can do that today, you just get a warning:
> 
> $ perl -wTe '@ary = ("Zaphod", "Ford", "Trillian"); $second_element = 
> @ary[1];'
> Scalar value @ary[1] better written as $ary[1] at -e line 1.
> Name "main::second_element" used only once: possible typo at -e line 1.

oh, i knew that.  but there were definite gotchas with confusing those
two syntaxes if you were, say, assigning from an open filehandle.
consider the massive difference between these two assignments:

  $arr[0] = FH ;
  @arr[0] = FH ;

as i recall, the first would simply read the next line (since this
was in a scalar context).

the second, however, would (because of the array context) read the
entire remainder of the file and throw away everything except for
the one line it assigned to the LHS.

this suggests that there *will* be major incompatibility problems
since using the "@" sigil will be the correct way to do this in
Perl 6.

anyway, back to reading the Perl 6 book.

rday




More information about the kw-pm mailing list