Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: join string in 2D array

by Anonymous Monk
on May 03, 2019 at 10:52 UTC ( [id://1233314]=note: print w/replies, xml ) Need Help??


in reply to join string in 2D array

$clk_new = join '_', $clk_output[$c];

You were almost there: $clk_output[$c] is a scalar that happens to contain an array reference, but join doesn't know that, since it takes a list. Dereference the scalar so it is transformed into a list in a function call, and the join works: join '_', @{$clk_output[$c]}.

You could also use a similar map construct to construct @clk_new with less code (C-style for loop in Perl is usually a sign of potential improvements): my @clk_new = map { join "_", @$_ } @clk_output;

All code is untested, sorry.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2024-04-18 07:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found