If we subclass our Person
class, we can override the size
attribute's default:
package Lilliputian;
use Moose;
extends 'Person';
has +size => ( default => "small" );
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use autobox; | |
package A; | |
sub call { print "A!\n" } |
use strict; | |
use warnings; | |
use subs::auto; | |
my %vars; | |
sub var (*) :lvalue { | |
my $var = shift; | |
no strict 'refs'; | |
no warnings 'redefine'; | |
*{$var} = sub { (\%vars)->{$var}; }; |
use strict; | |
use warnings; | |
use Coro; | |
my $offset = 0; | |
my $inc = 100; | |
my $max = 6; | |
my @coros; | |
my $stdout = "Incrementing \$offset by $inc...\n---\n"; |
fun string_length {n:nat} | |
(str: string n): size_t n = let | |
fun loop {i:nat | i <= n} | |
(str: string n, i: size_t i): size_t (n) = | |
if string_isnot_at_end (str, i) then loop (str, i+1) else i | |
in | |
loop (str, 0) | |
end | |
implement main () = begin |
val foo = '€'; | |
implement main () = () | |
(* | |
rsimoes@desktop:~/scratch/ats$ atscc uni_charsassign.dats | |
/usr/lib/ats-anairiats-0.2.5/bin/atsopt --output uni_charsassign_dats.c --dynamic uni_charsassign.dats | |
/home/rsimoes/scratch/ats/uni_charsassign.dats: LEXING ERROR: illegal character at [11(line=1, offs=11)] is unclosed! | |
exit(ATS): uncaught exception: _2fhome_2ffac2_2fhwxi_2fresearch_2fATS_2fIMPLEMENT_2fGeizella_2fAnairiats_2fsvn_2fats_2dlang_2fsrc_2flibats_lex_lexing_2esats__LexingErrorException(1235) | |
exit(ATS): [ccomp_file_to_file(uni_charsassign.dats, uni_charsassign_dats.c)] failed | |
*) |
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
sub myMap(&@) { | |
!wantarray && @_ - 1 || @_ > 1 && ( | |
do { | |
local $_ = $_[1]; | |
$_[0]->(); |
"What is 2 + 3?" . say . readline | |
. { 2 . 3 . add . eqn } | |
. { "Correct!" . say } . { "Incorrect" . say } | |
. ifte |
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; |
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(); |