This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Foo; | |
use Moo::Role; | |
use MooX::ClassAttribute; | |
class_has 'foo' => ( | |
is => 'ro', | |
isa => sub { $_[0] == 1 or die 'not 1' } | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package My::Types; | |
use strict; | |
use warnings; | |
use Type::Utils; | |
use Type::Library -base, | |
-declare => 'Percentage'; | |
use Types::Standard qw(Num); | |
use Math::BigFloat; |
OlderNewer