Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: One-liner to join keys on a two-dimensionnal hash ?

by johngg (Canon)
on Dec 29, 2021 at 15:11 UTC ( [id://11140010]=note: print w/replies, xml ) Need Help??


in reply to One-liner to join keys on a two-dimensionnal hash ?

Perhaps a bit simpler with values since the second-level hashes you are getting the keys of are the values of the first-level hash. However, if order is important you will have to sort keys in some fashion.

johngg@abouriou:~/perl/Monks$ perl -Mstrict -Mwarnings -E ' my %replaces = ( foo => { W100 => q{W102}, W101 => q{W103} }, bar => { W120 => q{W99}, W121 => q{W104} }, ); my $expr = join q{|}, map { keys %{ $_ } } values %replaces; say $expr;' W121|W120|W101|W100

I hope this is helpful.

Cheers,

JohnGG

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (9)
As of 2024-04-23 09:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found