=encoding utf8
=head1 NAME
=begin original
Text::Glob - match globbing patterns against text
=end original
Text::Glob - グロビングパターンによるテキストマッチング
=head1 SYNOPSIS
=begin original
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/;
}
=end original
use Text::Glob qw( match_glob glob_to_regex );
print "matched\n" if match_glob( "foo.*", "foo.bar" );
# foo.barと foo.bazが表示されます.
my $regex = glob_to_regex( "foo.*" );
for ( qw( foo.bar foo.baz foo bar ) ) {
print "matched: $_\n" if /$regex/;
}
=head1 DESCRIPTION
=begin original
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.
=head2 Routines
=over
=item match_glob( $glob, @things_to_test )
Returns the list of things which match the glob from the source list.
=item glob_to_regex( $glob )
Returns a compiled regex which is the equivalent of the globbing
pattern.
=item glob_to_regex_string( $glob )
Returns a regex string which is the equivalent of the globbing
pattern.
=back
=end original
Text::Globはテキストとのマッチングで使用することができる glob(3)スタイルの
マッチングを実装しています(ファイルシステムからファイル名を取得することより
テキストとのマッチングに適しています).
もし完全なファイルグロブを使いたい場合は File::Globモジュールを代わりに使ってください.
=head2 関数
=over
=item match_glob( $glob, @things_to_test )
入力として与えたリストで globとマッチした要素がリストとして返されます.
=item glob_to_regex( $glob )
指定したグロビングパターンと等価なコンパイル済み正規表現が返されます.
=item glob_to_regex_string( $glob )
指定したグロビングパターンと等価な文字列で表された正規表現が返ります.
=back
=head1 SYNTAX
=begin original
The following metacharacters and rules are respected.
=over
=item C<*> - match zero or more characters
C matches C, C, C and many many more.
=item C> - match exactly one character
C matches C, but not C, or C
=item Character sets/ranges
C matches C and C
C matches C, C, and C
=item alternation
C matches C, C, and
C
=item leading . must be explictly matched
C<*.foo> does not match C<.bar.foo>. For this you must either specify
the leading . in the glob pattern (C<.*.foo>), or set
C<$Text::Glob::strict_leading_dot> to a false value while compiling
the regex.
=item C<*> and C> do not match /
C<*.foo> does not match C. For this you must either
explicitly match the / in the glob (C<*/*.foo>), or set
C<$Text::Glob::strict_wildcard_slash> to a false value with compiling
the regex.
=back
=end original
関連するのは, 以下のメタ文字とルールになります.
=over
=item C<*> - 0以上の文字とのマッチ
Cは C, C, Cとその他たくさんのものとマッチします.
=item C> - ただ一つの文字とのマッチ
Cは Cにマッチしますが, Cや Cにはマッチしません.
=item 文字集合/範囲
Cは Cと Cにマッチします.
Cは C, C及び Cにマッチします.
=item 選択子.
Cは C, C及び
Cにマッチします.
=item 先頭の . は明示的にマッチさせる必要があります
C<*.foo>は C<.bar.foo>にマッチしません. このためグロブパターンに先頭の
. を明示的に指定するか, C<$Text::Glob::strict_leading_dot>を偽の値を
設定した場合に得られる, コンパイル済み正規表現を使う必要があります.
=item C<*>と C>は / にマッチしません
C<*.foo>は Cにマッチしません. このため / を明示的に
マッチさせるグロブ(C<*/*.foo>)か, C<$Text::Glob::strict_wildcard_slash>に
偽となる値を設定した場合に得られる, コンパイル済み正規表現を使う必要があります.
=back
=head1 BUGS
=begin original
The code uses qr// to produce compiled regexes, therefore this module
requires perl version 5.005_03 or newer.
=end original
コンパイル済みの正規表現を生成するために qw//を使っているため,
このモジュールを使うにはバージョンが 5.005_03以上の perlが必要となります.
=head1 AUTHOR
Richard Clamp
=head1 COPYRIGHT
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.
=head1 SEE ALSO
L, glob(3)
=cut