sub to_digits {
my $alphanum = lc shift;
my $res;
for (split //, $alphanum ) {
given ( $_) {
when (/[abc]/) { $res .= '2'}
when (/[def]/) { $res .= '3'}
Request->new($env);
my $params = $req->query_parameters;
my $q = $params->{q};
if ($q ~~ [undef, '', '*', '?']) {
# Just redirect if there is no search term.
unless ($q) {
or{badrequest},
vars => { param => 'q' },
});
}
unless ($params->{in} ~~ ['', undef, qw(docs dists extensions users tags)]) {
return $self->render('/badrequest', {
not valid Apache2 Listen directive syntax" };
subtype ApacheLogLevel,
as Str,
where { $_ ~~ @apache_log_levels },
message { "$_ is not a valid Apache2 log level. Must be one of " . join(
iptor item
# Expects the tag name followed by the data bytes
sub item
{
my $tag = shift;
given($tag)
{
# Handle Main items
when( 'collection' )
{
my $type = shift;
push @_, $c
ize(@_)), @_);
}
# Return an item's type given its tag
sub item_type
{
my $tag = shift;
given( $tags{$tag} & 0x0C )
{
when( 0x00 ) { return 'main' }
when( 0x04 ) { return 'global' }
wh
$v = shift @{$_[0]}; # Field initializer
next unless USB::HID::Report::Field->can($k);
given( ref($v) )
{
when('HASH') { push @fields, USB::HID::Report::Field->$k(%{$v}); }
when('AR
ent});
}
}
sub _to_add_in {
my ($seq, $letters_aref) = @_;
return ($seq->text_to_add ~~ $letters_aref);
}
{
# Dagesh qal.
# BET and PE must not change according to these rules i
of regular expression objects:
my @patterns = ( qr/Fr.d/, qr/B.rn.y/, qr/W.lm./ );
if( $string ~~ @patterns ) {
...
};
The smart match stops when it finds a match, so it doesn't have to try
e
x' is out of range.";
}
if (
not $self->_letter($let_idx)
~~ @{ $sets_seq->[$i] })
{
return;
}
}
return 1;
}
sub safe_mat
|
|-----------------------------------|
| ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |~~
$comments,
===================================
.
write STDOUT;
in Perl 6 we
har><1,$width>) /;
# Squeeze the resultant substring...
(my $result = $1) ~~ s:each/ <$ws> | \v+ /\c[SPACE]/;
# Check for any more data still to come...
r:
sub expurgate (Str *@hidewords) {
return sub (Str $data is rw) {
$data ~~ s:ei/(@hidewords)/$( 'X' x length $1 )/;
return $data;
}
}
We could then
/ @std_dirpath // '.';
@dirpath ^=~ s{([^/])$}{$1/};
[Update: Hyper smartmatch is now C<»~~«>.]
my %data;
foreach my $prefix (@dirpath) {
[Update: Now spelled:
for @d
any> Perl 6 subroutine. For
example:
sub mean (*@values : $type //= 'arithmetic') {
given ($type) {
when 'arithmetic': { return sum(@values) / @values; }
when 'geo
emantics.]
=item *
binary C<**>
=item *
binary C<=~> and C<!~>
[Update: Smartmatch is now C<~~>.]
=item *
binary C<*>, C</>, and C<%>
=item *
binary C<+> and C<->
=item *
binary C<< <<
Matcher
subset Matcher of Mu where none(Bool)
Used to supply a test to match against. Assume C<~~> will be used against it.
Booleans are forbidden because they almost always indicate a programming
e { .signature === :(Any, Any --> Int ) };
subset OrderingPair of Pair where { .left ~~ KeyExtractor && .right ~~ Comparator };
subset Ordering where Signature | KeyExtractor | Comparator | Orderin
against a type, you're likely better off
performing an C<isa> or C<does> or C<can>, or just C<$var ~~ TYPE>.
=item reset
Was there a I<good> use for this?
=item semctl, semget, semop
See IPC::SysV
C<when> statement, because:
when $is_sheep { push @sheep, $_ }
is equivalent to:
if $_ ~~ $is_sheep { push @sheep, $_; next }
When C<$is_sheep> is a subroutine reference, that implicit sm
my $context = want;
if $context ~~ List {
my @values = block();
return { *@values };
}
elsif $context ~~ Scalar {
my $value = block();
b help {
say <<'OUT';
usage:
install
upgrade
current-version
OUT
}
help unless $ARGV[0];
given ( $ARGV[0] ) {
when ('install') { install() }
when ('prepare-install') {
tatement?
In Perl 5.10, use the C<given-when> construct described in L<perlsyn>:
use 5.010;
given ( $string ) {
when( 'Fred' ) { say "I found Fred!" }
when( 'Barney' ) { say "I fo
is node's value : " . $node->string_value() . "\n" if $VERBOSE;
unless ( $node->string_value() ~~ $match ) {
die "XPath '$xpath' doesn't match '$match' as expected, instead it is '" . $nod
ode's value : " . $node->string_value() . "\n" if $VERBOSE;
unless ( $node->string_value() ~~ $match ) {
die "Elment $i of XPath '$xpath' doesn't match '$match' as expected, instea
"assert_xpath_value_match: This attr's value : " . $value . "\n" if $VERBOSE;
unless ( $value ~~ $match ) {
die "XPath '$xpath', attribute '$attr' doesn't match '$match' as expected, inst
ate_attributes;
}
my $meta_attr = $meta->get_attribute( $attribute_name );
my $return;
given ( ref $meta_attr ) {
when( 'Moose::Meta::Role::Attribute' ) {
$return = $meta_attr->ori
f->include_standard_methods ) {
my @STOCK = qw/ DESTROY meta new /;
return if $method_name ~~ @STOCK;
}
my $extracted_method = $self->_extract_method_metainfo( $meta_method );
$self->_
required if ACC is array, otherwise omit
use Test::More tests => 9; # ~~ Test::More::*
$trap->ACC_ok ( $ix, $name ); # ok()
# Check if a token is a known SQL keyword.
sub _is_keyword {
my ($self, $token) = @_;
return ~~ grep { $_ eq uc($token) } @{$self->{keywords}};
}
# Add new keywords to highlight.
sub add_keywo
ert{$op}
or $op eq '~~';
bless do {
($op eq '~~' or
($op =~ /[!=]=/ and ref $expect eq ref qr//))
, # == is overloaded when rhs is a regex
is 'abcd' ~~ q/bc/, # ~~ can be used with a string rhs in perl 5.10+
is 'badc' ~~ q/bc/;
test 'data structures',
is [1, 2, 3]
lt();
}
before 'run' => sub {
my ($self) = @_;
return unless ($self->auto_scale);
given (Scalar::Util::blessed($self)) {
when ('Hobocamp::Menu') {
$self->menu_height