in reply to Can I get help with Perl glob for filtering a directory
Works for me if I use a metacharacter so there's a dynamic pattern rather than a fixed string to match against. However, I generally prefer Path::Tiny for anything even slightly complex in this regard. Here are both approaches illustrated:
#!/usr/bin/env perl use strict; use warnings; use autodie; use Test::More tests => 2; use File::Glob qw( :globally :nocase); use Path::Tiny; open my $foo, '>', '/tmp/MisterPerl'; print $foo "Yeah!\n"; close $foo; my (@f) = glob ('/tmp/misterper[l]'); is $f[0], '/tmp/MisterPerl', 'File found case-insensitively with File: +:Glob'; @f = path ('/tmp')->children (qr/^misterperl/i); is $f[0], '/tmp/MisterPerl', 'File found case-insensitively with Path: +:Tiny';
Meta note: this node was apparently posted OK but not attached to the thread and then the content disappeared (see Re: Missing 'in reply to...' And 'in thread....'). I've restored the content now.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Can I get help with Perl glob for filtering a directory
by misterperl (Friar) on Nov 06, 2023 at 16:47 UTC | |
by NERDVANA (Priest) on Nov 06, 2023 at 19:23 UTC |