Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: Expression form of map or grep

by AnomalousMonk (Archbishop)
on Jul 12, 2020 at 01:56 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11119192]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (8)
As of 2024-04-18 06:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found