+sub _capture {
+ my $self = shift;
+ my $config;
+ $config->{capture} = $self->_validate(\%captures, $self->{capture}, @_);
+ $config->{greedy} = delete $config->{capture}->{greedy};
+ for (keys %captures) {
+ $config->{'c_' . $_} = $captures{$_}->($config, $config->{capture}->{$_})
+ if $captures{$_}; # Skip 'greedy'
+ }
+ $config;
+}
+
+sub capture {
+ my $self = shift;
+ _check_self $self;
+ my $config = $self->_capture(@_);
+ $self->{$_} = $config->{$_} for keys %$config;
+ $self;
+}
+
+sub _type {
+ my ($self, $type) = @_;
+ $type = 'unix' unless defined $type;
+ croak 'Wrong type' unless exists $types{$type};
+ my $config = $self->_do($types{$type});
+ $config->{type} = $type;
+ $config;
+}
+
+sub type {
+ my $self = shift;
+ _check_self $self;
+ my $config = $self->_type(@_);
+ $self->{$_} = $config->{$_} for keys %$config;
+ $self;
+}
+
+sub new {
+ my $class = shift;
+ $class = ref($class) || $class || __PACKAGE__;
+ croak 'Optional arguments must be passed as key => value pairs' if @_ % 2;
+ my %args = @_;
+ my $self = { };
+ bless $self, $class;
+ if (defined $args{do}) {
+ $self->do($args{do});
+ } else {
+ $self->type($args{type});
+ }
+ $self->capture($args{capture});
+}
+
+=head2 C<< new [ do => $what | type => $type ], capture => $captures >>
+
+Constructs a new L<Regexp::Wildcard> object.
+
+C<do> lists all features that should be enabled when converting wildcards to regexps. Refer to L</do> for details on what can be passed in C<$what>.
+
+The C<type> specifies a predefined set of C<do> features to use.
+
+
+C<$type> can be any of C<'jokers'>, C<'sql'>, C<'commas'>, C<'brackets'>, C<'win32'> or C<'unix'>. An unknown value defaults to C<'unix'>, except for C<'dos'>, C<'os2'>, C<'MSWin32'> and C<'cygwin'> that default to C<'win32'>. With this set of options, you can pass C<$^O> as the C<$type> so that you get the corresponding shell behaviour.
+
+=over 4
+
+=item C<>
+
+For the C<$capture> syntax, refer to the L</capture> method.
+
+=head3 C<type>
+
+=head3 C<capture>
+
+=over 4