y ($self, $type) = @_;
given ($type) {
when (STORED) { $self->{type} ~~ ATTR_STORED }
when (CACHED) { $self->{type} ~~ ATTR_CACHED }
when (KEY) { $self->{type} ~~ ATTR_KEY }
when (ANY
se { }
** unless (e) { } elsif (e) { } else { }
! ~ \ u+ u- given (e) { when (e) {} default {} }
=~ !~
* / % x NUMBERS vs STRINGS FALSE vs TR
== != eq ne
< > <= >= lt gt le ge < > <= >= lt gt le ge
== != <=> eq ne cmp ~~ <=> cmp
&
| ^ REGEX MODIFIERS REGEX METACHARS
&& /i c
erhaps you wanted: "
. ":where({ $param->{var} ~~ $match{where_expr} })"
)
: $ma
multi factorial ($n == 0) { 1 }
multi alert ($msg eq "") {}
multi alert ($msg ~~ undef) {}
multimethod add_client ($data, $ID =~ /X\w{4}\d{6}/) {
die "Can't add an X
{
return $_[0]->{postfix} // q~~ if !defined $_[1];
$_[0]->{postfix} = $_[1];
return $_[0]->{postfix};
}
sub prefix {
return $_[0]->{prefix} // q~~ if !defined $_[1];
$_[0]->{pre
fix} = $_[1];
return $_[0]->{prefix};
}
sub template {
return $_[0]->{template} // q~~ if !defined $_[1];
$_[0]->{template} = $_[1];
return $_[0]->{template};
}
sub handle_entry {
'eq' => sub{ &_op_overload( @_, 'IS' ) },
# Full Text Search operator
'~~' => sub{ &_op_overload( @_, '@@' ) },
fallback => 1,
);
use Wanted;
our $VE
are overloaded:
+, -, *, /, %, <, <=, >, >=, !=, <<, >>, lt, gt, le, ge, ne, &, |, ^, ==, eq, ~~
Thus a field named "dummy" could be used like:
$f + 10
which would become:
dummy + 10
ceholder in:
$f == "'JPY'"
Simply provide:
$f == '?'
You can use the search operator C<~~> for SQL Full Text Search and it would be converted into C<@@>:
Let's imagine a table C<articles>
eq | ne | lt | le | gt | ge
| == | != | < | <= | > | >=
| =~ | !~ | ~~
) \Z }x;
my $expected_code = $test_code;
my ($got_code, $comparator);
for m
ed[0];
ok $result eq $expected[0];
ok $result == $expected->[0]->{a}[0];
ok $result ~~ $expected[0];
ok $result !~ $expected[0];
ok $result > twice($expected{'half'});
=hea
$result --> 1
# $expected->[0]->{a}[0] --> undef
#
ok 4 - $result ~~ $expected[0]
not ok 5 - $result !~ $expected[0]
# Failed test at demo/ts_ok-er.pl line 1
concat_amg, /* 0x3f . */
concat_ass_amg, /* 0x40 .= */
smart_amg, /* 0x41 ~~ */
ftest_amg, /* 0x42 -X */
regexp_amg, /* 0x43 qr */
max_amg_code
emented on this Perl version"
# 52 implicit smartmatch in given/when
given ('foo') {
when ('bar') { continue; }
when ($_ ~~ 'quux') { continue; }
default { 0; }
}
####
# 53 conditions in e
ve caught it
earlier.
=item Repeated format line will never terminate (~~ and @# incompatible)
(F) Your format contains the ~~ repeat-until-blank sequence and a
numeric field that will never go blan
.
=item Smart matching a non-overloaded object breaks encapsulation
(F) You should not use the C<~~> operator on an object that does not
overload it: Perl refuses to use the object's underlying stru
[ 1, 2, 0 ], 0 ];
$e = '"abc" ~~ (%s)';
$subs{'~~'} = $e;
push @tests, [ "abc", $e, '(~~)', '(NM:~~)', [ 1, 1, 0 ], 0 ];
$subs{'-X'} = 'do { my $f = (%s);'
nc may be used together.
=item *
The smartmatch operator (C<~~>) was changed so that the right-hand side
takes precedence during C<Any ~~ Object> operations.
=item *
A bug has been fixed in the ta
er> and inherits from L<Markdown::Parser::Element>
For example:
Tickets for the event are ~~€5~~ ++€10++
Which would become:
Tickets for the event are <del>€5</del> <ins>€10</ins>
shift(@via_main);
# FIXME cannot smartmatch $stop since it became an object
# if ( $stop ~~ \@via_show or $stop == $last_stop ) {
# next;
# }
push( @via_show, $stop );
}
}
meta = $Aion::META{$pkg};
my $extends = $meta->{extends} // return "";
return 1 if $class ~~ $extends;
for my $extender (@$extends) {
return 1 if $extender->isa($class);
}
elf;
my $meta = $Aion::META{$pkg};
my $does = $meta->{with} // return "";
return 1 if $role ~~ $does;
for my $doeser (@$does) {
return 1 if $doeser->can("does") && $doeser->does($ro
/^ ( (?: (?: ~~ )*+ ~ \[ | [^\[] )++ ) /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
@_;
return match { return $_ ~~ $match for $sub->() };
}
sub any {
my @possibilities = @_;
return match {
for my $candidate (@possibilities) {
return 1 if $_ ~~ $candidate;
}
return;
};
rn match { scalar hash and [ sort keys %{$_} ] ~~ [ sort keys %{$hash} ] };
}
sub value {
my $value = shift;
return $value if blessed($value);
given (ref $value) {
when ('') {
return $value;
NAME
Smart::Match - Smart matching utilities
=head1 VERSION
version 0.008
=head1 SYNOPSIS
given ($foo) {
say "We've got a positive number" when positive;
say "We've got an array" when
output items; if item is a reference, will print dump
=cut
sub debug {
my $layer = $_[0] && $_[0] ~~ @Layer_const ? shift : DefaultLayer;
# drop the layer prefix to print in a config-fasion manner
tput OFF
=cut
sub _verbose {
my $layer = shift;
my $conf = Crop->C->{debug};
return 1 unless $conf->{output} eq 'On';
return unless exists $conf->{layer};
$layer ~~ @{$conf->{layer}};
}
1;
output items; if item is a reference, will print dump
=cut
sub debug {
my $layer = $_[0] && $_[0] ~~ @Layer_const ? shift : DefaultLayer;
# drop the layer prefix to print in a config-fasion manner
tput OFF
=cut
sub _verbose {
my $layer = shift;
my $conf = Crop->C->{debug};
return 1 unless $conf->{output} eq 'On';
return unless exists $conf->{layer};
$layer ~~ @{$conf->{layer}};
}
1;
NV{PERL_MEM_LOG} =~ /t/ include timestamp in Log
$ENV{PERL_MEM_LOG} =~ /^(\d+)/ write to FD given (default is 2)
Memory logging is somewhat similar to C<-Dm> but is independent of
C<-DDEBUGGING>
ry hash-ref, and returns
true if the document matches the query, false otherwise. If no query
is given (or an empty hash-ref is given), true will be returned (every
document will match an empty query