trantorvega has asked for the wisdom of the Perl Monks concerning the following question:

Personal test:
$ perl -e '@a = qw/1222 2 3/; while (<@a>) { print $_ ."\n";}' 1222 2 3
From the documentation it doesn't seem the above ought to work, but it does. Anyone knows why?

Replies are listed 'Best First'.
Re: Diamond operator iterating over arrays?
by almut (Canon) on Oct 28, 2009 at 23:31 UTC

    I think the <...> acts as a glob here:

    In scalar context, glob iterates through such filename expansions, returning undef when the list is exhausted.
      That's right, and the array is imply interpolated into the string.

      You can see that by interpolating an array with items that contain whitespaces:

      $ perl -e '@a = ("2 3", 4); while (<@a>) { print $_ ."\n";}' 2 3 4
      Perl 6 - links to (nearly) everything that is Perl 6.