Group
Extension

Matches 1354

Aion ( D/DA/DART/Aion-0.4.tar.gz, DART, 2025; MetaCPAN )
Aion/lib/Aion/Types.pm ( view source; MetaCPAN )
l", as &Item, where { ref $_ eq "" and /^(1|0|)\z/ };
		subtype "Enum[A...]", as &Item, where { $_ ~~ ARGS };
		subtype "Maybe[A]", as &Item, where { !defined($_) || A->test };
		subtype "Undef", as &
qr/\bkitty\b/i],
	        message { "Speak is'nt included kitty!" };
	}
	
	"Kitty!" ~~ SpeakOfKitty # -> 1
	"abc" ~~ SpeakOfKitty 	 # -> ""
	
	eval { SpeakOfKitty->validate("abc", "This") }; "$@" # ~>
	
	
	BEGIN {
		subtype IntOrArrayRef => as (Int | ArrayRef);
	}
	
	[] ~~ IntOrArrayRef  # -> 1
	35 ~~ IntOrArrayRef  # -> 1
	"" ~~ IntOrArrayRef  # -> ""
	
	
	coerce IntOrArrayRef, from Num, via { int
Switch-Right ( D/DC/DCONWAY/Switch-Right-0.000006.tar.gz, DCONWAY, 2025; MetaCPAN )
Switch-Right/lib/Switch/Right.pm ( view source; MetaCPAN )
|/]{1,2}+  (?! [=]  )
                    |    \^              (?! [=]  )
                    |    ~~ | isa
                    )
              )
          )
          $PPR::GRAMMAR
      }xms;
}

# I
te @pure_statements;
    @pure_statements = ();
    state $VALIDATE_PURE_GIVEN = qr{
        \A  given (?<GIVEN>  (?<ws_post_kw>   $OWS    )  \(
                             (?<JUNC>     (?: $OWS (?> 
document describes Switch::Right version 0.000006


=head1 SYNOPSIS

    use Switch::Right;

    given ($value) {
        when (undef)    { say 'an undefined value'                         }
        w
Benchmark-Perl-Formance-Cargo ( S/SC/SCHWIGON/perl-formance/Benchmark-Perl-Formance-Cargo-0.07.tar.gz, SCHWIGON, 2012; MetaCPAN )
Benchmark-Perl-Formance-Cargo/share/P6STD/STD.pm6 ( view source; MetaCPAN )
str(self.orig,$pos++,1);
    if $char ~~ /^\s$/ {
        self.panic("Whitespace character is not allowed as delimiter"); # "can't happen"
    }
    elsif $char ~~ /^\w$/ {
        self.panic("Alphanu
     $text ~= $ch;
                            $to = $¢.pos;
                            if $ch ~~ "\n" {
                                $multiline++;
                            }
               
.pos - self.pos);
            my ($inside) = $all ~~ m!^...\s*(.*?)\s*.$!;
            $¢.obs("Perl 5's $all construct", "a smartmatch like \$! ~~ $inside" );
        }
    }

    token special_var
FAST ( D/DH/DHARD/FAST-1.06.tar.gz, DHARD, 2015; MetaCPAN )
FAST/lib/FAST/List/Gen.pm ( view source; MetaCPAN )
], [b => 2], [c => 3]);

in scalar context, C< tuples > returns a generator:

    tuples(...)  ~~  zipwith {\@_} ...

=cut

    sub tuples {
        unless (wantarray) {
            unshift 
s by default

=over 4

=item * B<iteration>:

    $gen->next       # iterates over generator ~~ $gen->get($gen->index++)
    $gen->()         # same.  iterators return () when past the end

 
$gen->filter(do {my %seen; sub {not $seen{$_}++}})
    $gen->deref       # tuples($a, $b)->deref  ~~  zip($a, $b)

=item * B<combinations>:

    $gen->zip($gen2, ...)  # takes any number of gener
perl ( E/EH/EHERMAN/perl-5.43.4.tar.gz, DROLSKY, 2025; MetaCPAN )
perl/pod/perlop.pod ( view source; MetaCPAN )
nonassoc	named unary operators
    nonassoc	< > <= >= lt gt le ge
    nonassoc	== != <=> eq ne cmp ~~
    left	&
    left	| ^
    left	&&
    left	|| //
    nonassoc	..  ...
    right	?:
    right	= +
r greater than the right
argument.
X<cmp>

Binary "~~" does a smartmatch between its arguments.  Smart matching
is described in the next section.
X<~~>

"lt", "le", "ge", "gt" and "cmp" use the collat
tmatch Operator

First available in Perl 5.10.1 (the 5.10.0 version behaved differently),
binary C<~~> does a "smartmatch" between its arguments.  This is mostly
used implicitly in the C<when> constru
Aion ( D/DA/DART/Aion-0.4.tar.gz, DART, 2025; MetaCPAN )
Aion/lib/Aion/Type.pm ( view source; MetaCPAN )
 @_;
		__PACKAGE__->new(name => "Exclude", args => [$type1], test => sub { !$type1->test });
	},
	"~~" => "include",
;

# конструктор
# * args (ArrayRef) — Список аргументо
ion::Type;
	
	my $Int = Aion::Type->new(name => "Int", test => sub { /^-?\d+$/ });
	12   ~~ $Int # => 1
	12.1 ~~ $Int # -> ""
	
	my $Char = Aion::Type->new(name => "Char", test => sub { /^.\z/ });
	$C
har;
	77   ~~ $IntOrChar # => 1
	"a"  ~~ $IntOrChar # => 1
	"ab" ~~ $IntOrChar # -> ""
	
	my $Digit = $Int & $Char;
	7  ~~ $Digit # => 1
	77 ~~ $Digit # -> ""
	
	"a" ~~ ~$Int; # => 1
	5   ~~ ~$Int; # 
List-Gen ( A/AS/ASG/List-Gen-0.974.tar.gz, ASG, 2011; MetaCPAN )
List-Gen/lib/List/Gen.pm ( view source; MetaCPAN )
], [b => 2], [c => 3]);

in scalar context, C< tuples > returns a generator:

    tuples(...)  ~~  zipwith {\@_} ...

=cut

    sub tuples {
        unless (wantarray) {
            unshift 
s by default

=over 4

=item * B<iteration>:

    $gen->next       # iterates over generator ~~ $gen->get($gen->index++)
    $gen->()         # same.  iterators return () when past the end

 
$gen->filter(do {my %seen; sub {not $seen{$_}++}})
    $gen->deref       # tuples($a, $b)->deref  ~~  zip($a, $b)

=item * B<combinations>:

    $gen->zip($gen2, ...)  # takes any number of gener
Sidef ( T/TR/TRIZEN/Sidef-24.11.tar.gz, TRIZEN, 2024; MetaCPAN )
Sidef/lib/Sidef/Object/Object.pm ( view source; MetaCPAN )
 ~~ RangeString
                if (UNIVERSAL::isa($second, 'Sidef::Types::Range::RangeString')) {
                    return $second->contains($first);
                }

                # String ~~ 
           if (UNIVERSAL::isa($first, 'Sidef::Types::Number::Number')) {

                # Number ~~ RangeNumber
                if (UNIVERSAL::isa($second, 'Sidef::Types::Range::RangeNumber')) {
   
  if (UNIVERSAL::isa($first, 'Sidef::Types::Range::RangeNumber')) {

                # RangeNumber ~~ Number
                if (UNIVERSAL::isa($second, 'Sidef::Types::Number::Number')) {
            
Unicode-Tussle ( B/BR/BRIANDFOY/Unicode-Tussle-1.122.tar.gz, BRIANDFOY, 2025; MetaCPAN )
Unicode-Tussle/lib/Unicode/Tussle.pm ( view source; MetaCPAN )
d(NUM) && () ~~ [1..10]' | less -r
    unichars 'defined(NUM) && [1..10] ~~ NUM' | less -r
    unichars 'defined(NUM) && [1..1] ~~ NUM' | less -r
    unichars 'defined(NUM) && ! (NUM() ~~ [0..10])' | 
less -r
    unichars 'defined(NUM) && ! NUM() ~~ [0..10]' | less -r
    unichars 'defined(NUM) && NUM <= 10'
    unichars 'defined(NUM) && NUM <= 10' | less
    unichars 'defined(NUM) && NUM <= 10' | 
less -r
    unichars 'defined(NUM) && ! NUM() ~~ [1..10]' | less -r
    unichars 'defined(NUM) && NUM() ~~ [1..10]' | less -r
    unichars '\d' '\p{common}'
    unichars '\d' '\p{Latin}
    unichars '
Unicode-Tussle ( B/BR/BRIANDFOY/Unicode-Tussle-1.122.tar.gz, BRIANDFOY, 2025; MetaCPAN )
Unicode-Tussle/script/oscon-whatis.pod ( view source; MetaCPAN )
d(NUM) && () ~~ [1..10]' | less -r
    unichars 'defined(NUM) && [1..10] ~~ NUM' | less -r
    unichars 'defined(NUM) && [1..1] ~~ NUM' | less -r
    unichars 'defined(NUM) && ! (NUM() ~~ [0..10])' | 
less -r
    unichars 'defined(NUM) && ! NUM() ~~ [0..10]' | less -r
    unichars 'defined(NUM) && NUM <= 10'
    unichars 'defined(NUM) && NUM <= 10' | less
    unichars 'defined(NUM) && NUM <= 10' | 
less -r
    unichars 'defined(NUM) && ! NUM() ~~ [1..10]' | less -r
    unichars 'defined(NUM) && NUM() ~~ [1..10]' | less -r
    unichars '\d' '\p{common}'
    unichars '\d' '\p{Latin}
    unichars '
Text-CSV ( A/AL/ALANCITT/Text-CSV-0.01.tar.gz, HMBRAND, 1997; MetaCPAN )
Text-CSV/Text-CSV-0.007/lib/Text/CSV.pm ( view source; MetaCPAN )
$!text ~~ m{^ <[0..9]> } ?? +$!text
            !!                              $!text.unival.Int
            !! Num;
        }

    method Real {
        $!text.defined
            ?? $!text ~~ m{^ <
   return; # Default is False for both

        $!text ~~ m:m{^ <[ \x09, \x20 .. \x7E ]>+ $} or
            $!is_binary = True;

        $!text ~~ m:m{^ <[ \x00       .. \x7F ]>+ $} or
            $!i
                      $!sep ~~ m{<[\r\n]>}   and self!fail (1003);
        $!quo.defined and $!quo ~~ m{<[\r\n]>}   and self!fail (1003);
        $!esc.defined and $!esc ~~ m{<[\r\n]>}   and self!fail
Data-DPath ( S/SC/SCHWIGON/Data-DPath-0.60.tar.gz, SCHWIGON, 2024; MetaCPAN )
Data-DPath/lib/Data/DPath.pm ( view source; MetaCPAN )
 $resultlist = $data ~~ dpath '/AAA/*/CCC';        # [ ['XXX', 'YYY', 'ZZZ'], [ 'RR1', 'RR2', 'RR3' ] ]

Note that the C<match()> function returns an array but the overloaded
C<~~> operator returns an
ove data structure):

 $data ~~ dpath '/AAA/*/CCC'
 $data ~~ dpath '/AAA/BBB/CCC/../..'    # parents  (..)
 $data ~~ dpath '//AAA'                 # anywhere (//)
 $data ~~ dpath '//AAA/*'            
  # anywhere + anystep
 $data ~~ dpath '//AAA/*[size == 3]'    # filter by arrays/hash size
 $data ~~ dpath '//AAA/*[size != 3]'    # filter by arrays/hash size
 $data ~~ dpath '/"EE/E"/CCC'          
perl ( E/EH/EHERMAN/perl-5.43.4.tar.gz, DROLSKY, 2025; MetaCPAN )
perl/pod/perlsyn.pod ( view source; MetaCPAN )
hin a C<foreach>
loop or a C<given> block, it executes the statement only if the smartmatch
C<< $_ ~~ I<EXPR> >> is true.  If the statement executes, it is followed by
a C<next> from inside a C<foreac
XPR) BLOCK elsif (EXPR) BLOCK ...
    unless (EXPR) BLOCK elsif (EXPR) BLOCK ... else BLOCK

    given (EXPR) BLOCK

    LABEL while (EXPR) BLOCK
    LABEL while (EXPR) BLOCK continue BLOCK

    LABEL
 to use the highly experimental C<given>, that could be
written like this:

    use v5.10.1;
    given ($var) {
	when (/^abc/) { $abc = 1 }
	when (/^def/) { $def = 1 }
	when (/^xyz/) { $xyz = 1 }
	def
Lingua-EN-Inflexion ( D/DC/DCONWAY/Lingua-EN-Inflexion-0.002009.tar.gz, DCONWAY, 2024; MetaCPAN )
Lingua-EN-Inflexion/lib/Lingua/EN/Inflexion.pm ( view source; MetaCPAN )
turns true if any one pair of
inflexions matches (case-insensitively).

That is:

    noun($word1) ~~ noun($word2)

is just a shorthand for:

       lc(noun($word1)->singular)          eq lc(noun($wor
 is then smartmatched
against the other argument.

That is:

    $something_else ~~ noun($word1)
       noun($word1) ~~ $something_else

are just slightly shorter (and less order-specific) ways of wri
 ~~ noun($word2)         # (ditto)

    noun($word1) =~ $word2         # $word1 matches $word2 exactly

    noun($word1) ~~ $word2         # any inflexion of $word1 matches $word2

    noun($word1) ~~
Type-Tiny ( T/TO/TOBYINK/Type-Tiny-2.008004.tar.gz, TOBYINK, 2025; MetaCPAN )
Type-Tiny/lib/Types/Standard.pm ( view source; MetaCPAN )
y::Package";
   \%h ~~ Tied;                   # true
   \%h ~~ Tied[ $My_Package ];    # true
   \%h ~~ Tied["My::Package"];    # true
   
   tie my $s, "Other::Package";
   \$s ~~ Tied;             
      # true
   $s  ~~ Tied;                   # false !!

If you need to check that something is specifically a reference to
a tied hash, use an intersection:

   use Types::Standard qw( Tied HashRef
hRef);
   
   tie my %h, "My::Package";
   tie my $s, "Other::Package";
   
   \%h ~~ $TiedHash;     # true
   \$s ~~ $TiedHash;     # false

=item *

B<< StrMatch[`a] >>

A string that matches a regu
Type-Tiny ( T/TO/TOBYINK/Type-Tiny-2.008004.tar.gz, TOBYINK, 2025; MetaCPAN )
Type-Tiny/lib/Type/Tiny/Manual/NonOO.pod ( view source; MetaCPAN )
ngWithMoo3>.

=head2 Type::Tiny and Smart Match

Perl 5.10 introduced the smart match operator C<< ~~ >>, which has since
been deprecated because though the general idea is fairly sound, the details
w
qw( Str Int );
  
  given ( $value ) {
    when ( Int ) { ... }
    when ( Str ) { ... }
  }

This will do what you wanted:

  use Types::Standard qw( is_Str is_Int );
  
  given ( $value ) {
    when
Perl-Tidy ( S/SH/SHANCOCK/Perl-Tidy-20250912.tar.gz, SHANCOCK, 2025; MetaCPAN )
Perl-Tidy/lib/Perl/Tidy/Tokenizer.pm ( view source; MetaCPAN )
r term is expected
        # next.
        if ( $rsquare_bracket_type->[$square_bracket_depth] eq '~~' ) {
            $tok = $rsquare_bracket_type->[$square_bracket_depth];
        }

        if ( $s
'||=' => undef,
        ##  '//=' => undef,
        ##  '~'   => undef,
        ##  '~~'  => undef,
        ##  '!~~' => undef,

    };

    # ---------------------------------------------------------
|| >= != mm *= => .. !~ == && |= .= pp -= =~ += <= %= ^= x= ~~ ** << /=
      &= // >> ~. &. |. ^.
      ... **= <<= >>= &&= ||= //= <=> !~~ &.= |.= ^.= <<~
      #;
    push @q, ',';
    push @q, '('
Perl-Tidy ( S/SH/SHANCOCK/Perl-Tidy-20250912.tar.gz, SHANCOCK, 2025; MetaCPAN )
Perl-Tidy/lib/Perl/Tidy/VerticalAligner.pm ( view source; MetaCPAN )
]                  ~~ [];
            #  [ ["foo"], ["bar"] ] ~~ [ qr/o/, qr/a/ ];
            #  [ qr/o/, qr/a/ ]     ~~ [ ["foo"], ["bar"] ];
            #  [ "foo", "bar" ]     ~~ [ qr/o/, qr/a/ ];

            #  [ qr/o/, qr/a/ ]     ~~ [ "foo", "bar" ];
            #  $deep1               ~~ $deep1;

            # So we will use two thresholds.
            my $nmin_mono     = $depth + 2;
     
he same left side patterns, so we will align the equals.
    #     my $orig = my $format = "^<<<<< ~~\n";
    #     my $abc  = "abc";
    # But these have a different left pattern so they will not be
perl ( E/EH/EHERMAN/perl-5.43.4.tar.gz, DROLSKY, 2025; MetaCPAN )
perl/pod/perl5120delta.pod ( view source; MetaCPAN )
in in
subsequent 5.10 releases.

=head3 Changes to type-based dispatch

The smart match operator C<~~> is no longer commutative. The behaviour of
a smart match now depends primarily on the type of its
t like the other code references (even if they
choose to ignore it).

=item *

C<%hash ~~ sub {}> and C<@array ~~ sub {}> now test that the subroutine
returns a true value for each key of the hash (or
 are no longer
treated specially when appearing on the left of the C<~~> operator,
but like any vulgar scalar.

=item *

C<undef ~~ %hash> is always false (since C<undef> can't be a key in a
hash). No
perl ( E/EH/EHERMAN/perl-5.43.4.tar.gz, DOM, 2025; MetaCPAN )
perl/pod/perl5110delta.pod ( view source; MetaCPAN )
es.

=head2 Smart match changes

=head3 Changes to type-based dispatch

The smart match operator C<~~> is no longer commutative. The behaviour of
a smart match now depends primarily on the type of its
t like the other code references (even if they
choose to ignore it).

=item *

C<%hash ~~ sub {}> and C<@array ~~ sub {}> now test that the subroutine
returns a true value for each key of the hash (or
 are no longer
treated specially when appearing on the left of the C<~~> operator,
but like any vulgar scalar.

=item *

C<undef ~~ %hash> is always false (since C<undef> can't be a key in a
hash). No

Powered by Groonga
Maintained by Kenichi Ishigaki <ishigaki@cpan.org>. If you find anything, submit it on GitHub.