] ~~ [];
# [ ["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;
ame 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
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
] = $retfile;
print RETBLOCK "$retfile\n";
if ( not ($retfile ~~ @retcases ) )
{
push ( @retcases, $retfile );
} @miditers = Sim::OPT::washn( @miditers );
if ( not ( $retfile ~~ @{ $notecases[ $countcase ][ $countblock ][ $counttool ][ $countinstance ] } ) )
es = uniq( @retcases );
my $retfile = $resfile;
if ( not ($retfile ~~ @retcases ) )
{
push ( @retcases, $retfile );
my @mro = @{ mro::get_linear_isa( ref $obj ) };
for my $class ( @mro ) {
my $name = "$class\::(~~";
my $overload = do {
no strict 'refs';
exists( &$name ) ? \&$name : undef;
};
return
if (match($this, $that))
{
say "$this matches $that";
}
=head2 Differences with ~~
There were major changes to smart match between 5.10.0 and 5.10.1. This
module attempts to emulat
smart's operator does not.
@foo ~~ %bar # means: \@foo ~~ \%bar
@foo |M| %bar # means: scalar(@foo) |M| scalar(%bar)
If you want the C<< \@foo ~~ \%bar >> behaviour, you need to add
^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~~
$role_reqs
.
format INHERIT_POD =
=head1 NAME
@*
$mycl
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~~
$handles
.
format ATTR_NARROW
$handles
^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~~
$handles
.
format ATTRHEAD_POD =
=head1 ATTRIBUTES
.
format ATTR_POD =
^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~~
$role_reqs
.
format INHERIT_POD =
=head1 NAME
@*
$myclass
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~~
$handles
.
format ATTR_NARROW
$handles
^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~~
$handles
.
format ATTRHEAD_POD =
=head1 ATTRIBUTES
.
format ATTR_POD =
=he
N = '0.003'; # VERSION
my $text = <<'_';
**About smart match**
Smart matching, via the operator `~~`, was introduced in perl 5.10 (released
2007). It's probably inspired by Perl 6 (now called Raku)'
tr ~~ @ary`, probably the most common
use-case for smart matching, can do value-in-array checking, equivalent to `grep
{ $str eq $_ } @ary` but with short-circuiting capability. Then there's `$re ~~
@
ch::smart> (as `|M|` operator or as function `match`) gives you a
similar behaviour to perl's own `~~`.
<pm:match::simple>, also by the author of `match::smart`, offers a simplified
version of smart
blockelts_r };
foreach my $key ( sort ( keys %varns ) )
{
if ( not( $key ~~ @blockelts ) )
{
$varns{$key} = 1;
}
}
return( %va
{
foreach my $key ( sort ( keys( %varnums ) ) )
{
if ( not( $key ~~ @blockelts ) )
{
$modhs{$key} = $varnums{$key};
$torecover
foreach my $instance ( @{ $vehicles{cumulateall} } )
{
if ( $instance->{is} ~~ @reds )
{
my @instancees;
push( @instancees, $instance );
esfile, $shortflfile );
#if ( ( $dowhat{simulate} eq "y")
# and ( ( ( not ( $to{cleanto} ~~ ( @trieds ) ) ) or ( not ( $precious eq "" ) ) )
# or ( ( $gaproc eq "yes" ) and ( $fire eq
";
if ( ( not ( $resfile ~~ @simcases ) ) and ( not ( -e $resfile ) ) and ( $dowhat{simulate} eq "y")
and ( not ( $to{cleanto} ~~ ( @trieds ) ) ) )
{
print SIMBLOCK "$resfile\n";
}
if ( ( not ( $resfile ~~ @retcases ) ) and ( not ( -e $resfile ) ) )
{
push ( @simcases, $res
if ($in ~~ Array && $in.elems > 0) {
$type ~= $in.list[0].WHAT.gist;
$type ~~ s{")("} = " of ";
}
my Str $s-in = sprintf "%-16s %s", $type, $in.gist;
$s-in ~~ s:g{\n}
> $csv), "Sub/Obj { s-in ($in) }");
}
# Test supported "out" formats
my $datn = $data; $datn ~~ s:g{ "\r\n" } = "\n";
for in () -> $in {
is (csv (in => $in, out => Str, :!quote-space), $data
return wantarray ? $start : ($start, $end);
}
my $tag;
given ($opt{role})
{
when (undef)
{
defined $t;
}
else
{
given ($node->get_tag)
{
when ('text:tab')
}
my $tag;
my %attr = $opt{attributes} ? %{$opt{attributes}} : ();
given ($opt{type})
{
when (["lexical", "alphabetical"])
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
rd 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 (\&i
lters, [$f, $ftype, "~~", $args->{"$f.has"}, $ftype, $cic];
}
if (defined $args->{"$f.lacks"}) {
$exists++;
push @filters, [$f, $ftype, "!~~", $args->{"$f.lacks
q 'truth') {
next REC if $r_h->{$f} xor $opn;
} elsif ($op eq '~~') {
if ($stringy) {
if ($cic) {
} @{$r_h->{$f}};
}
}
} elsif ($op eq '!~~') {
if ($stringy) {
if ($cic) {
/^ ( (?: (?: ~~ )*+ ~ \[ | [^\[] )++ ) /x;
$raw //= '';
if (length $raw) {
$text =~ s/^ ( (?: (?: ~~ )*+ ~ \[ | [^\[] )++ ) //gx;
# Fix up escapes
$raw =~ s/(?:~~)*+\K~\[/[/g;
$raw =~ s/(?:~~)*+\K~,/,/g;
$raw =~ s/~~/~/g;
# Escape stuff for perl
$raw =~ s/\\/\\\\/g;
$raw =~ s/'/\\'/g;
$sub .= ", '$raw'";
}
last unless length $tex
$method =~ s/ \[ \s* (.*?) \s* \] /$1/x;
# sort out ~, and ~~
$method =~ s/(?:~~)*+\K~,/\x{00}/g;
$method =~ s/~~/~/g;
($method, my @params) = split /,/, $method;
# if $is_p
eginning with $word
local $CWD = "/home";
return [grep {-d && $_ ~~ /^\Q$word/} <*>];
},
},
force => {schema=>[bool => {default=>0}]},
grep {-d && $_ ~~ /^\Q$word/} <*>];
# exclude users already mentioned by user
my $ary = $args{args}{usernames};
$res = [grep {!($_ ~~ @$ary)}] @$res
opy(d);
}
else
d = &PL_sv_undef;
assert(e);
if (SvGMAGICAL(e))
e = sv_mortalcopy(e);
/* ~~ undef */
if (!SvOK(e)) {
return !SvOK(d);
}
else if (SvROK(e)) {
/* First of all, handle ov
SV* sv = amagic_call(d, e, smart_amg, AMGf_noleft);
if (sv)
return SvTRUEx(sv);
}
/* ~~ qr// */
if (SvTYPE(SvRV(e)) == SVt_REGEXP) {
dSP;
REGEXP* re = (REGEXP*)SvRV(e);
PMOP*
urn result;
}
/* Non-overloaded object */
else if (SvOBJECT(SvRV(e)))
return d == e;
/* ~~ sub */
else if (SvTYPE(SvRV(e)) == SVt_PVCV) {
dSP;
ENTER_with_name("smartmatch_array_elem
st operators
nonassoc < > <= >= lt gt le ge
nonassoc == != <=> eq ne cmp ~~
left &
left | ^
left &&
left |
now 0
my $z = "c" cmp "b"; #$x is now positive
=head3 See also
L</X E<lt>=E<gt> Y>
=head2 X ~~ Y
=head3 Class
This belongs to L<perlop/Equality Operators>.
=head3 Description
This is the sm
ead.
=head3 Example
See L<perlsyn/"Smart matching in detail"> for examples.
=head3 See also
L</~~X>, L<perlsyn/"Smart matching in detail">, and L<perlfunc/scalar>
=head2 X & Y
=head3 Class
This
sep, ",", "Sep = ,");
for < , ; > -> $sep {
my Str $data = "bAr,foo\n1,2\n3,4,5\n";
$data ~~ s:g{ "," } = $sep;
$csv.column-names (False);
{ my $fh = IO::String.new: $data;
ok (my
,", ";" ];
for ",", ";", "|", "\t" -> $sep {
my Str $data = "bAr,foo\n1,2\n3,4,5\n";
$data ~~ s:g{ "," } = $sep;
$csv.column-names (False);
{ my $fh = IO::String.new: $data;
ok (my
>], "Headers");
}
for < , ; > -> $sep {
my Str $data = "bAr,foo\n1,2\n3,4,5\n";
$data ~~ s:g{ "," } = $sep;
$csv.column-names (False);
{ my $fh = IO::String.new: $data;
ok (my
my $fh = open "test.csv", :r, chomp => False;
while (my @row = $csv.getline($fh)) {
@row[2] ~~ m/pattern/ or next; # 3rd field should match
@rows.push: @row;
}
$fh.close;
# and wri
cept and C<False>
for records to reject.
csv (in => "file.csv", filter => {
$^row[2] ~~ /a/ && # third field should contain an "a"
$^row[4].chars > 4 # length of the 5th fi
at have no visible data
This filter is a shortcut for
filter => { $^row.first: { .defined && $_ ~~ /\S/ }}
This filter rejects all lines that I<not> have at least one field that does
not evaluate
alert "Grouping not allowed"; return FALSE;
}
my $tag = ($type ~~ ['column', 'row']) ?
'table:table-' . $type . '-group' :
{
$min //= $v; $max //= $v;
given ($type)
{
when (['string', 'all']