+sub convert {
+ my ($self, $wc, $type) = @_;
+ _check_self $self;
+ my $config;
+ if (defined $type) {
+ $config = $self->_type($type);
+ } else {
+ $config = $self;
+ }
+ return unless defined $wc;
+ my $do = $config->{do};
+ my $e = $config->{escape};
+ $wc =~ s/(?<!\\)((?:\\\\)*[^\w\s\\$e])/\\$1/g;
+ if ($do->{jokers}) {
+ $wc = $self->_jokers($wc);
+ } elsif ($do->{sql}) {
+ $wc = $self->_sql($wc);
+ }
+ if ($do->{brackets}) {
+ $wc = $self->_bracketed($wc);
+ } elsif ($do->{commas}) {
+ if ($wc =~ /(?<!\\)(?:\\\\)*,/) { # win32 allows comma-separated lists
+ $wc = $self->{'c_brackets'} . $self->_commas($wc) . ')';
+ }
+ }
+ return $wc;
+}
+
+=head1 EXPORT
+
+An object module shouldn't export any function, and so does this one.
+
+=head1 DEPENDENCIES
+
+L<Carp> (core module since perl 5), L<Text::Balanced> (since 5.7.3).
+
+=head1 CAVEATS
+
+This module does not implement the strange behaviours of Windows shell that result from the special handling of the three last characters (for the file extension). For example, Windows XP shell matches C<*a> like C<.*a>, C<*a?> like C<.*a.?>, C<*a??> like C<.*a.{0,2}> and so on.