f, but how do we apply these rules to a string other than C<$_>?
We use the smart match operator C<~~>. This operator is called "smart
match" because it does quite a bit more than just apply regular
expression against the string contained in a variable called C<$foo>,
we'd do this:
$foo ~~ / <regex here> /;
There's a more general syntax that allows the author to choose
different delimi
h the
C</> character and you don't feel like writing C<\/> so much:
$foo ~~ m/ <regex here> /;
$foo ~~ m! <regex here> !; # different delimiter
=head3 Modifiers
The more genera
>access_token,
token_secret => $self->access_secret,
);
}
if ($method ~~ ['POST', 'PUT']) {
my $u = URI->new('http:');
if (@args) {
push @extra
) = @_;
return if $line =~ /(^#|^\n)/;
my ($key, $value) = split /\s+/, $line;
$self->{$key} = (
$key ~~ @has_scope ?
[split /\?/, $value] :
$value
);
}
1;
%attrs = map {
my $asref = $self->meta->find_attribute_by_name($_)->type_constraint->name ~~ /Ref/;
$_, $entry->get_value($_, asref => $asref);
} $entry->attributes;
return (
# This is much simpler with the ~~ operator, but Perl 5.10
# features are being avoided until 5.10 is standard both on MacOSX
# and Debian
# Note that the ~~ operator only checks keys of h
ashes, not values
# unless(%atts1 ~~ %atts2)
unless($attkeys1 eq $attkeys2)
{
debug(3," elements have different attributes");
return 0;
}
foreach my $att (keys %at
$value = $list->index(0);
my ($key, $value) = $map->index(0);
Returns the value at the index given (zero starting). Returns a list if a map type. Returns undef or () if not present. Throws L<Th
args) = parse_line('\s+', 0, $cmd);
next PROMPT unless $thiscmd;
unless ( lc($thiscmd) ~~
[ qw/h help q quit open create freeze thaw/ ]
) {
unless ( $self->_get_curr
( index($args[0], '--') == 0 ) {
my $f_opt = shift @args;
substr($f_opt, 0, 2, '');
given (lc($f_opt//'')) {
$format = 'YAMLXS' when "yaml";
$format = 'YAML' when "syck";
( index($args[0], '--') == 0 ) {
my $f_opt = shift @args;
substr($f_opt, 0, 2, '');
given (lc($f_opt//'')) {
$format = 'YAMLXS' when "yaml";
$format = 'YAML' when "syck";
}
default {
die q(I don't know what to do with $foo);
}
}
C<given(EXPR)> will assign the value of EXPR to C<$_>
within the lexical scope of the block, so it's simi
he power comes from implicit smart matching:
when $foo
is exactly equivalent to
when $_ ~~ $foo
In fact C<when EXPR> is treated as an implicit smart match most of the
time. The exceptions
ral array
or hash as the argument to C<when>, it is turned into a
reference. So C<given(@foo)> is the same as C<given(\@foo)>,
for example.
C<default> behaves exactly like C<when True>, which is
to s
he current parameter
set.
=item strip_like($regex)
Remove all parameters whose names match the given (qr-quoted) regex e.g.
$qq->strip_like(qr/^utm/)
Does NOT match against parameter values.
le-colon, dash or slash
$opts{cpan} =~ s![/-]!::!g if $opts{cpan};
# "If no argument is given (but the switch is specified - not specifying
# the switch will include everything), it defau
ess ref $self->report;
return unless defined $self->report->status
and $self->report->status ~~ [qw/DONE FAIL/];
return $self->report->status
}
sub failed {
my ($self, $reason) = @_;
i
ump {
my ($self) = @_;
return unless ref $self->report;
return unless $self->report->status ~~ [ qw/DONE FAIL/ ];
return $self->report->netinfo
}
sub report { info(@_) }
sub info {
my ($s
sub mk_query_to_server {
my ( $self, $method, $url, $params ) = @_;
unless ( $method ~~ [ qw( POST GET ) ] ) {
confess "Unknown request method: '$method'";
}
confess "UR
my $package = $params->{package};
unless ( $self->{fake_answer} ) {
unless ( $package ~~ $self->show_packages() ) {
return {error => 1, text => "No such package $package on server"};
h my $obj (@{$array}) {
while ( my ($key, $value) = each %{$obj} ) {
if ( $key ~~ @special_keys ) {
$self->_date_to_datetime($value);
}
$obj
for a pathway will be available
for many individuals, meaning that we now have many tests of the given (single)
hypothesis.
(This should not be confused with the scenario of multiple hypothesis
testin
############
# ===
# NEW create a new population path-scan object
# === ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
=head2 new
The object constructor takes a mandatory, but otherwise un-ordere
gn the manner in which genes will be internally organized
# ====== ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
=head2 assign
This method assigns the manner in which genes will b
$call, $isaRef, @params ) = @_;
for my $param ( @params )
{
given ( $param )
{
# Define singleton class
# via use param
=> $pkg
};
for ( @attrs )
{
given( $_ )
{
when ('Public' ) { makePublic ($call,$pkg,$sym,$r
e of property.
sub addProperty
{
my ( $this, $attr, $value ) = @_;
given( $attr )
{
when( /^__/ ) { return addPrivate(@_) }
when( /^_/ )
class = shift;
my $self = {};
bless $self, $class;
return $ReproxySelf = $self;
}
# given (clientproxy, primary_res_hdrs), initiate proceedings to process a
# request for a reproxy resour
e what commands
would be sent to gnuplot. This is a dry run. Note that if the 'binary' option is
given (see below), then this dump will contain binary data. If this binary data
should be suppressed fr
gnuplot I<and> to the log. Useful for debugging I/O issues. Note that
if the 'binary' option is given (see below), then this log will contain binary
data. If this binary data should be suppressed fro
# now try to get it processing again
MogileFS::ProcManager->ProcessQueues;
}
}
# given (job, pid), record that this worker is about to die
# $level is so we can tell if watchdog reques
($class, $name) = @_;
my @leaves = @{$class->leaves} if $class->can("leaves");
if ( $name ~~ @leaves ) {
return $class . "::" . ucfirst($name);
} else {
return 0;
}
}