RE: [perl #46543] Strange behavior of map inside @{}  > print "@{ +map [1, 2, 3, $_], (4) }" # prints nothing

In scalar context map returns the number of elements generated.
@{ ... } is a scalar context, expecting some sort of reference.
Here, map returns 1 in scalar context, and print prints @{1}.

% perl -lwe 'print "@{ +map [1, 2, 3, $_], (4) }"'

% perl -Mstrict -lwe  'print  "@{ +map [1, 2, 3, $_], (4) }"'
Can't use string ("1") as an ARRAY ref while "strict refs" in use at -e line 1

% perl -lwe '@1 = qw(Hello world); print "@{ +map [1, 2, 3, $_], (4) }"'
Helloworld


However, this works:
% perl -lwe 'print "@{ (map [1, 2, 3, $_], (4))[0] }"'
1234

Robin

-------------------------------------------------------------------
This e-mail and any attachments may contain confidential and/or
privileged material; it is for the intended addressee(s) only.
If you are not a named addressee, you must not use, retain or
disclose such information.

NPL Management Ltd cannot guarantee that the e-mail or any
attachments are free from viruses.

NPL Management Ltd. Registered in England and Wales. No: 2937881
Registered Office: Serco House, 16 Bartley Wood Business Park,
                   Hook, Hampshire, United Kingdom  RG27 9UY
-------------------------------------------------------------------

