in reply to Creating arrays with glob patterns without metacharacters
it could cause unintended and confusing side effects
It's of course a matter of opinion, but I do agree with this - it's a neat but somewhat obscure use of glob. It can be useful, as it allows one to generate combinations using just core Perl, without loading e.g. Algorithm::Combinatorics. But all it takes is someone who doesn't know the details ("If non-empty braces are the only wildcard characters used ...") or the interpolation of unchecked variables into the pattern for it to break. Personally, my feeling is that in a one-off script, or with a fixed string plus a comment warning future maintainers, it's ok to use. But if you want to play it safe with respect to future maintainers, I'd avoid it.
As for using <a b c> as a replacement for qw/a b c/, sure it's clever, but IMO it's a silly place to save two characters, and I'd probably recommend against it. Also, I like to use File::Glob ':bsd_glob';, which breaks it:
$ perl -le 'print for <a b c>' a b c $ perl -MFile::Glob=:bsd_glob -le 'print for <a b c>' a b c
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Creating arrays with glob patterns without metacharacters
by Lotus1 (Vicar) on Jan 05, 2018 at 17:09 UTC |