Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^2: Expression form of map or grep

by AnomalousMonk (Bishop)
on Jul 12, 2020 at 01:56 UTC ( #11119192=note: print w/replies, xml ) Need Help??


in reply to Re: Expression form of map or grep
in thread Expression form of map or grep

I think @list will not contain anything from @grey_scale, and would warn with something like "Useless use of private array in void context" ...

Ah, good catch!

c:\@Work\Perl\monks\Lady_Aleena>perl -wMstrict -MData::Dump -le "my @colors = qw(a b c); my @grey_scale = qw(x y); my @list = map( qq{$_ beads}, @colors ), @grey_scale; dd \@list; " Useless use of private array in void context at -e line 1. ["a beads", "b beads", "c beads"]
Another set of parentheses is needed to include the second (and any subsequent) array:
c:\@Work\Perl\monks\Lady_Aleena>perl -wMstrict -MData::Dump -le "my @colors = qw(a b c); my @grey_scale = qw(x y); my @list = (map( qq{$_ beads}, @colors ), @grey_scale); dd \@list; " ["a beads", "b beads", "c beads", "x", "y"]


Give a man a fish:  <%-{-{-{-<

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11119192]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2020-10-01 17:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (16 votes). Check out past polls.

    Notices?