in reply to Combinations of lists to a hash
You could regex your input to form a glob pattern:
main::(-e:1): 0 DB<1> x <Prefix1={A,B}:{c,d}> 0 'Prefix1=A:c' 1 'Prefix1=A:d' 2 'Prefix1=B:c' 3 'Prefix1=B:d' DB<2> @keys = <Prefix1={A,B}:{c,d}> DB<3> @hash{@keys} = ('value1') x @keys
> (which I'd rather not bore you with)
That's a bad approach because first it wasn't clear for me what you are trying to achieve.
Especially because %hash = {...} is broken Perl. :)
HTH!
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
FootballPerl is like chess, only without the dice
A demo to build the glob pattern:
DB<22> ($pre,@comb) = split /=|:/, "Prefix1=A,B:c,d" DB<23> p $pattern = "$pre=" . join ":", map { "{$_}" } @comb Prefix1={A,B}:{c,d} DB<24> x <"$pattern"> 0 'Prefix1=A:c' 1 'Prefix1=A:d' 2 'Prefix1=B:c' 3 'Prefix1=B:d' DB<25>
NB: You should take care to properly escape potential meta characters like * or ?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Combinations of lists, etc
by AnomalousMonk (Archbishop) on Oct 04, 2019 at 15:17 UTC | |
by tel2 (Pilgrim) on Oct 05, 2019 at 01:22 UTC | |
by AnomalousMonk (Archbishop) on Oct 07, 2019 at 00:15 UTC | |
by tel2 (Pilgrim) on Oct 07, 2019 at 02:13 UTC | |
Re^2: Combinations of lists, etc
by The Perlman (Scribe) on Oct 04, 2019 at 16:23 UTC | |
by AnomalousMonk (Archbishop) on Oct 04, 2019 at 17:20 UTC | |
by LanX (Saint) on Oct 04, 2019 at 17:26 UTC | |
by AnomalousMonk (Archbishop) on Oct 04, 2019 at 20:43 UTC | |
by LanX (Saint) on Oct 04, 2019 at 22:44 UTC | |
by LanX (Saint) on Oct 04, 2019 at 17:23 UTC | |
by 1nickt (Canon) on Oct 04, 2019 at 17:00 UTC | |
by The Perlman (Scribe) on Oct 04, 2019 at 17:35 UTC |