in reply to Re^8: Combinations of lists, etc
in thread Combinations of lists to a hash

The only way I can see right now to deal with * vis-a-vis glob is to replace it with a character that occurs nowhere else in your data. So maybe (if tybalt89 hasn't already solved this):

c:\@Work\Perl\monks\tel2>perl -wMstrict -MData::Dump -le "use constant NEVER_PRESENT => qq{\x01}; ;; my $s = 'Prefix5,Prefix6:A,B:*:1,23 value7=10|value88=123'; ;; $s =~ s{ [*] }{${ \NEVER_PRESENT }}xmsg; ;; my ($keyule, $valule) = split ' ', $s, 2; ;; $keyule =~ s{ : }[}:{]xmsg; $keyule = qq[{$keyule}]; print qq{'$keyule'}; $valule =~ s{ [|] }{,}xmsg; $valule = qq[{$valule}]; print qq{'$valule'}; ;; my %hash; for my $v (glob $valule) { my ($vk, $vv) = split '=', $v; for my $k (glob $keyule) { $k =~ s{ ${ \NEVER_PRESENT } }{*}xmsg; $hash{$k}{$vk} = $vv; } } dd \%hash; " '{Prefix5,Prefix6}:{A,B}:{☺}:{1,23}' '{value7=10,value88=123}' { "Prefix5:A:*:1" => { value7 => 10, value88 => 123 }, "Prefix5:A:*:23" => { value7 => 10, value88 => 123 }, "Prefix5:B:*:1" => { value7 => 10, value88 => 123 }, "Prefix5:B:*:23" => { value7 => 10, value88 => 123 }, "Prefix6:A:*:1" => { value7 => 10, value88 => 123 }, "Prefix6:A:*:23" => { value7 => 10, value88 => 123 }, "Prefix6:B:*:1" => { value7 => 10, value88 => 123 }, "Prefix6:B:*:23" => { value7 => 10, value88 => 123 }, }
Ok, now what's the next phase in the dance-of-the-seven-veils requirement disclosure?

Update: BTW: I'm still not convinced that glob is the way to go with this application. An algorithmic permuter (update: such as haukex describes) or parser would be more to my liking, but it's your project.


Give a man a fish:  <%-{-{-{-<

Replies are listed 'Best First'.
Re^10: Combinations of lists, etc
by tel2 (Pilgrim) on Oct 08, 2019 at 02:20 UTC
    Nice work, AnomalousMonk.  Thanks for that.

    Why would you prefer replacing the '*' (and reverting it after the 'glob'), over escaping it (which requires no reverting afterwards), e.g.:
    $s =~ s/\*/\\$&/g;

      Because I couldn't get it to work. :)

      Update: I thought I had that working, but it doesn't seem to work now, and I don't have time ATM to mess with it.


      Give a man a fish:  <%-{-{-{-<

        No need to bother with it, AnomalousMonk.  Just wondered if there was a good reason.

        Thanks for all your other help.