cdarke has asked for the wisdom of the Perl Monks concerning the following question:
Or am I wrong? This really puzzles me, because it has been around for so long.sub glob2pat { my $globstr = shift; my %patmap = ( '*' => '.*', '?' => '.', '[' => '[', ']' => ']', '-' => '-', # Added by me ); $globstr =~ s{(.)} { $patmap{$1} || "\Q$1" }ge; return '^' . $globstr . '$'; }
$globstr =~ s{(?:^|(?<=[^\\]))(.)} { $patmap{$1} || "\Q$1" }ge;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Bug in glob2pat?
by cdarke (Prior) on Sep 03, 2008 at 08:46 UTC | |
|
Re: Bug in glob2pat?
by Anonymous Monk on Sep 02, 2008 at 14:35 UTC | |
by JadeNB (Chaplain) on Sep 02, 2008 at 14:43 UTC | |
by cdarke (Prior) on Sep 02, 2008 at 15:01 UTC | |
by JadeNB (Chaplain) on Sep 02, 2008 at 15:04 UTC | |
by broomduster (Priest) on Sep 02, 2008 at 15:35 UTC | |
by cdarke (Prior) on Sep 02, 2008 at 16:40 UTC | |
|
Re: Bug in glob2pat?
by Anonymous Monk on Sep 02, 2008 at 14:43 UTC | |
by shmem (Chancellor) on Sep 02, 2008 at 17:18 UTC | |
by cdarke (Prior) on Sep 02, 2008 at 15:19 UTC |