Moose
DBIx::Class
----
Modern
Perl?
----
perl5
v10
----
given ($x) {
when (3) {
...
----
~~
----
what's the
opposite?
----
Old
Perl?
----
if it
wor
(1)
----
~~
----
~~@x
----
~(~(@x))
----
bitwise
negation
----
so ...
----
~@x
->
~(scalar @x)
----
~~$number
->
$number
----
~~@x
->
-MMoose -e'print ~~keys %INC'
84
----
overload::constant
----
lets you
affect
parsing
----
numbers
strings
----
q qq qr
t s qw
----
i18n.pm
----
~~"$foo bar"
loc(
};
}
elsif ( PERL510 and $hints ) {
$code .= qq{
if ( \@results ~~ \$hints->{list} ) { $die };
};
}
elsif ( $hints ) {
croak sprintf(ERROR_58
};
}
elsif (PERL510 and $hints) {
return $code . qq{
if ( \$retval ~~ \$hints->{scalar} ) { $die };
$retval_action
return \$retval;
};
>) these methods will return the current value of
the option, else the option will be set to the given (scalar) value and the old setting will be
returned.
=cut
sub auto_array { return shift -> _c
unless ( grep { $_caller eq $_ } @__FRIENDS__ );
#unless ( $_caller ~~ @__FRIENDS__ );
}
$_[0]->[1]->{$fn};
};
less ( grep { $_caller eq $_ } @__FRIENDS__ );
#unless ( $_caller ~~ @__FRIENDS__ );
}
$_[0]->[0]->[$p];
less ( grep { $_caller eq $_ } @__FRIENDS__ );
#unless ( $_caller ~~ @__FRIENDS__ );
}
$_[0]->[1]->{$fn};
foreach my $server (@$task_servers) {
push @$servers, $server->{name} unless $server->{name} ~~ $servers;
}
}
# expand server list into hashrefs, adding info from db if available
# TODO: a
ith the letters 'f' or 'n'. Case is
## ignored.
coerce PA_Bool
, from Str
, via {
my $arg;
given ( $_ ) {
when ( qr/on/i ) { $arg = 1 }
when ( qr/off/i ) { $arg = 0 }
when ( qr/^[t
;
}
;
## Furthers the volume functionality
coerce PA_Volume
, from Str , via {
my $ratio;
given ( $_ ) {
when ( 'MAX' ) { $ratio = FULL_VOLUME }
when ( 'HALF' ) { $ratio = 0.50 * FULL_VO
C:\WINDOWS\SoftwareDistribution\SelfUpdate\WUClient-SelfUpdate-Aux-TopLevel~31bf3856ad364e35~amd64~~7.2.6001.788.mum</td> </tr>
<tr> <td class="foot" align="center">5</td> <td class="foot" align="c
C:\WINDOWS\SoftwareDistribution\SelfUpdate\WUClient-SelfUpdate-Core-TopLevel~31bf3856ad364e35~amd64~~7.2.6001.788.mum</td> </tr>
<tr> <td class="foot" align="center">4</td> <td class="foot" align="c
return $config;
}
sub parse_virt_host
{
my ($self, $config, $virt) = @_;
given (lc($virt->{host}->{root}->{precondition_type})) {
when ('image') {
ed a raw image to copy PRC stuff to
no warnings 'uninitialized';
given($guest->{root}{mounttype})
{
when ('raw') {
path not from user, Safe.pm deactivated for debug and speed
my $producers = $precondition ~~ dpath '//*[key eq "precondition_type" and lc(value) eq "produce"]/../..';
foreach my $prod
$entry = $pkg->get(@names);
}
elsif (my $ref = ref $entry)
{
given ($ref)
{
when ('HASH') { $entry = defined $entry->{$p}? $entry->{$p}
ntry;
$tailref = ref $tailref eq 'HASH'? $tailref->{$_}: $tailref->[$_] foreach (@tail);
given (ref $tailref)
{
when ('HASH') { if (defined $data) { $tailref->{$tail} = $data } el
4 ] }, c => \"string" };
=end testing
=cut
sub clone
{
my $ref = $_[0];
my $result;
given (ref $ref)
{
when ('HASH') { $result = { map { $_ => clone($ref->{$_}) } keys %$ref
for my $worker ( @{ $pidref->{$master} } ) {
if ( ref($worker) ~~ 'HASH' ) {
for ( keys %$worker ) {
print "
item is
contained in an array or a hash:
use 5.010;
if( $item ~~ @array )
{
say "The array contains $item"
}
if( $item ~~ %hash )
{
say "The hash contains $item"
}
With earlier ver
ons like "NaN" or
"Infinity", you probably just want to use a regular expression:
use 5.010;
given( $number ) {
when( /\D/ )
{ say "\thas nondigits"; continue }
when( /^\d+\z/ )
{ say "\
ptions ) = @_;
my $template = [ $spec ];
while ( my ( $k, $v ) = each %$spec ) {
given ( ref $v ) {
when ('') { $$template[FOR_DATA]{ $v } = _data_control $k }
so ~~ $rx ) {
# substr($iso, $/.from, $/.chars) = $rx();
# }
#}
($iso ~~ rx:perl5/(YYYY)/) && (substr($iso,$/.from,$/.chars)= sprintf("%04d", $year))
or
($iso ~~ r
100)))
or undefine($year);
$iso ~~ rx:perl5/(WNN)/ && (substr($iso,$/.from,$/.chars)=sprintf("W%02d", $week)) or undefine($week);
$iso ~~ rx:perl5/(MM)/ && (substr($iso,$/.from,$/.ch
"%02d", $month)) or undefine($month);
$iso ~~ rx:perl5/(DDD)/ && (substr($iso,$/.from,$/.chars)=sprintf("%03d", $doy)) or undefine($doy);
$iso ~~ rx:perl5/(DD)/ && (substr($iso,$/.from,$/.char
py {
$field.trans(('_' => '-')) if not $field ~~ /^\:/ and $TRANSLATE_UNDERSCORE;
my $v = %!headers.delete($field.lc);
push @values, $v ~~ Array ?? @$v !! $v if defined $v;
}
return @
my method header (Str $field is copy, Str $val is copy, Str $op = "") {
unless $field ~~ /^\:/ {
$field ~~ s:g/_/-/ if $TRANSLATE_UNDERSCORE;
my $old = $field;
$field = lc $field;
un
entry for this field
$old ~~ s:g/\b(\w)/{$0.ucfirst}/;
%standard_case{$field} = $old;
}
}
my $h = %!headers{$field};
$h //= [];
my @old = $h ~~ Array ?? @$h !! ($h);
$val =
$self = shift;
my $d1 = RPG::Dice->new('1d6');
my $d2 = RPG::Dice->new('2d6');
given ( $d2->roll() ) {
when (2) {
$self->type(A);
}
when ( [ 3 ..
e(G);
}
when ( [ 10 .. 12 ] ) {
$self->type(F);
}
}
given ( $d2->roll() ) {
when (2) {
$self->size(II);
}
when (3) {
ector" );
sub getSpectralClass {
my $self = shift;
my $d1 = RPG::Dice->new('1d6');
given ( $d1->roll() ) {
when ( [ 1, 3, 5 ] ) {
my $roll = ( $d1->roll() ) + 4;
self->{$dialog}, $boot) : $self->{$dialog};
}
## @method hide_dialog($dialog)
# @brief Hide the given (name of a) dialog.
sub hide_dialog {
my($self, $dialog) = @_;
$self->{$dialog.'_position
et_widget($dialog)->hide();
}
## @method $dialog_visible($dialog)
#
# @brief Return true is the given (name of a) dialog is visible.
sub dialog_visible {
my($self, $dialog) = @_;
my $d = $sel
lf->detectLanguage($text);
my $pair = lc($text_lang . "-" . $to);
unless (@$language_pairs ~~ /($pair)/) {
croak "Unsupported languege pair";
}
my $response = $self->getXmlResp
e.yandex.net/api/v1/tr/translate?lang=$pair&text=$text");
my $code = $response->{code};
given ($code) {
when (200) {break;}
when (413) {croak "The text size exceeds the maximu
}
}
my @pids = keys %processes;
if ($pid_file ~~ @pids and exists $processes{$pid_file}[2] and $processes{$pid_file}[2] == 0) {