in reply to Re^2: Challenge: Generate a glob patterns from a word list
in thread Challenge: Generate a glob patterns from a word list

> OP updated. Don't count the curlies and commas.

you should also add that curlies and commas should be minimal as a second criteria.

for instance a , {a} and {{a}} are all equivalent.

best you provide a sub metric

edit

sub cmp_glob($g1,$g2) which returns -1, 0 or 1 like cmp does.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^4: Challenge: Generate a glob patterns from a word list
by choroba (Cardinal) on May 06, 2021 at 09:37 UTC
    > for instance a , {a} and {{a}} are all equivalent.

    Interestingly, we've found a place where Perl's glob behaves differently to the brace expansion in bash:

    $ perl -wE 'say glob "{{a}}"' a $ echo {{a}} {{a}}

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

      I tend to side with the shell here. Braces which don't enclose a comma are not a glob pattern (for me).


      🦛

        I disagree, behavior should be consistent.

        The glob could be constructed with a

        $str = join ",", @list

        part between the curlies

        glob "$start{$str}$end"

        and fail for @list < 2

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        Wikisyntax for the Monastery