Text::Glob(3pm) | User Contributed Perl Documentation | Text::Glob(3pm) |
Text::Glob - match globbing patterns against text
use Text::Glob qw( match_glob glob_to_regex ); print "matched\n" if match_glob( "foo.*", "foo.bar" ); # prints foo.bar and foo.baz my $regex = glob_to_regex( "foo.*" ); for ( qw( foo.bar foo.baz foo bar ) ) { print "matched: $_\n" if /$regex/; }
Text::Glob implements glob(3) style matching that can be used to match against text, rather than fetching names from a filesystem. If you want to do full file globbing use the File::Glob module instead.
The following metacharacters and rules are respected.
"demo.[a-c]" matches "demo.a", "demo.b", and "demo.c"
The code uses qr// to produce compiled regexes, therefore this module requires perl version 5.005_03 or newer.
Richard Clamp <richardc@unixbeard.net>
Copyright (C) 2002, 2003, 2006, 2007 Richard Clamp. All Rights Reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
File::Glob, glob(3)
2022-10-13 | perl v5.34.0 |