Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Dynamically create a foreach loop within a foreach loop?

by tobyink (Canon)
on Dec 11, 2013 at 10:57 UTC ( [id://1066596]=note: print w/replies, xml ) Need Help??


in reply to Dynamically create a foreach loop within a foreach loop?

use strict; use warnings; use List::MapMulti; my %sizes = (big => 'L', small => 'S'); my %colours = (red => '001', blue => '002', black => '000'); my %origins = (American => 'US', Japanese => 'JP', German => 'DE'); my %products = (car => '0001', truck => '0004'); my @hashes = (\%sizes, \%colours, \%origins, \%products); my @hash_keys = map [sort keys %$_], @hashes; mapm { my @keys = @_; my @values = map $hashes[$_]{$_[$_]}, 0 .. $#_; my $product_desc = join q[ ], @keys; my $product_code = join q[-], @values; printf "%s - %s\n", $product_code, $product_desc; } @hash_keys;
use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name

Replies are listed 'Best First'.
Re^2: Dynamically create a foreach loop within a foreach loop?
by PerlSufi (Friar) on Dec 11, 2013 at 15:42 UTC
    If I could vote this response more than once, I would..

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-04-19 03:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found