Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

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

by tobyink (Canon)
on Dec 11, 2013 at 10:57 UTC ( #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? | Other CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2022-01-21 00:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (57 votes). Check out past polls.

    Notices?