Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

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

by johngg (Canon)
on Dec 29, 2021 at 15:11 UTC ( #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? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2023-01-28 06:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?