If we subclass our Person
class, we can override the size
attribute's default:
package Lilliputian;
use Moose;
extends 'Person';
has +size => ( default => "small" );
package My::Types; | |
use strict; | |
use warnings; | |
use Type::Utils; | |
use Type::Library -base, | |
-declare => 'Percentage'; | |
use Types::Standard qw(Num); | |
use Math::BigFloat; |
package Foo; | |
use Moo::Role; | |
use MooX::ClassAttribute; | |
class_has 'foo' => ( | |
is => 'ro', | |
isa => sub { $_[0] == 1 or die 'not 1' } | |
); |
use Set::Builder qw(Set Var for_all); | |
# set constructor, roster style: | |
my $set = Set { 0..9 }; | |
# element variable constructor: | |
my ($x, $y) = (Var) x 2; | |
# subset consisting of the numbers 0 and 1 | |
my $subset1 = Set { $x ~~ $set | $x ~~ Set { 0..1 } }; |
#!/usr/bin/env perl | |
use v5.14; | |
use warnings; | |
use AnyEvent::HTTP "http_get"; | |
use Variable::Magic qw(wizard cast dispell); | |
use Data::Alias "alias"; | |
use PadWalker "peek_my"; | |
sub get_page { |
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use Data::Dump; | |
use Data::Alias "alias"; | |
use Scalar::Util qw(weaken isweak); | |
my $foo = ["a".."z"]; | |
alias my @bar = @$foo; |
use IO::Socket::IP; | |
use Socket qw(SOCK_STREAM) | |
use Net::GnuTLS::Client; | |
use Net::GnuTLS::Credentials; | |
# Connect to server: | |
my $socket = IO::Socket::IP->new( | |
PeerHost => "metacpan.org", | |
PeerPort => "https", |
use Socket qw(getaddrinfo SHUT_RDWR SOCK_STREAM); | |
use Net::GnuTLS qw(GNUTLS_CLIENT GNUTLS_CRD_CERTIFICATE GNUTLS_SHUT_RDWR | |
GNUTLS_X509_FMT_PEM); | |
my %hints = ( socktype => SOCK_STREAM ); | |
my ( $err, $addr_info ) = getaddrinfo( "metaperl.org", "echo", \%hints ); | |
socket( my $SKT, @{$addr_info}{qw(family type protocol)} ) || die "socket: $!"; | |
connect( $SKT, $addr_info->{addr} ) || die "connect: $!"; | |
my $creds = Net::GnuTLS::Certificate::allocate_credentials(); |
use v5.14; | |
use strict; | |
use warnings; | |
use utf8::all; | |
use Data::Dump; | |
use LWP::Simple qw(get); | |
use Benchmark qw(cmpthese timethese); | |
use XML::LibXML; | |
use XML::Parser; | |
use XML::SAX::PurePerl; |
"What is 2 + 3?" . say . readline | |
. { 2 . 3 . add . eqn } | |
. { "Correct!" . say } . { "Incorrect" . say } | |
. ifte |