Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^3: Joining Arrays?

by kyle (Abbot)
on Dec 21, 2008 at 04:45 UTC ( [id://731850]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Joining Arrays?
in thread Joining Arrays?

I agree with that. It would be nice if map (and grep) could take a variable like foreach does.

# this doesn't work my @joined = map my $url { map my $code { $url . $code } @codes } @urls;

Replies are listed 'Best First'.
Re^4: Joining Arrays?
by pobocks (Chaplain) on Dec 21, 2008 at 06:07 UTC

    I guess, but I actually find that version harder to read than the first version. For one thing, it has no indentation options that aren't kind of terrible.

    For the general, non-nested versions, it might be nicer.

    for(split(" ","tsuJ rehtonA lreP rekcaH")){print reverse . " "}print "\b.\n";
Re^4: Joining Arrays?
by pKai (Priest) on Dec 21, 2008 at 17:26 UTC

    If the map BLOCK is more complicated than [insert personal threshold here], or they are nested I just declare the variable myself.

    @joined = map { my $url = $_; map { my $code = $_; $url . $code; } @codes } @urls;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2024-04-19 11:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found