View perl-print.pl
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 strict; | |
use warnings; | |
{ | |
local $\ = "\n"; # output record separator | |
local $| = 1; # autoflush | |
print "Hello"; | |
print "World"; | |
} |
View import_export.pl
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
sub import { | |
shift; | |
@_ = 'with' unless @_; | |
Keyword::Simple::define $_, \&__rewrite_with for @_; | |
} | |
sub unimport { | |
shift; | |
@_ = 'with' unless @_; | |
Keyword::Simple::undefine $_ for @_; |
View get-weather.pl
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 v5.16; | |
use HTTP::Tiny; | |
use JSON::PP 'decode_json'; | |
my ( $lat, $lon ) = ( 54.5, -1.55 ); | |
my $url = sprintf( | |
'https://api.open-meteo.com/v1/forecast?latitude=%s&longitude=%s'. | |
'&daily=temperature_2m_max,temperature_2m_min&timezone=Europe/London', | |
$lat, | |
$lon, |
View monty.pl
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 MySim; | |
use Zydeco; | |
use List::Util qw( shuffle sample ); | |
# Next line shouldn't be needed, but I guess a bug somewhere in Zydeco... | |
BEGIN { package MySim::Types; use Type::Library -base; } | |
class Door { | |
param prize ( type => Bool, default => false, is => ro ); |
View example.pl
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 v5.40; | |
use Local::Animal; | |
sub default_species :scalar { | |
return "Guinea Pig"; | |
} | |
my $geoffrey = Local::Animal->new( | |
name => "Geoffrey", |
View fortune-500.pl
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
#!perl | |
use strict; | |
use warnings; | |
use constant { | |
THOUSAND => 1_000, | |
MILLION => 1_000_000, | |
BILLION => 1_000_000_000, | |
}; |
View hue-mood.pl
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.16; | |
use warnings; | |
package ColourSet { | |
use Moo; | |
use Types::Standard -types; | |
has initial => ( |
View cpanm-5.6.pl
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 | |
# | |
# This is a pre-compiled source code for the cpanm (cpanminus) program. | |
# For more details about how to install cpanm, go to the following URL: | |
# | |
# https://github.com/miyagawa/cpanminus | |
# | |
# Quickstart: Run the following command and it will install itself for | |
# you. You might want to run it as a root with sudo if you want to install | |
# to places like /usr/local/bin. |
View my-perltidy
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 Perl::Tidy; | |
exit Perl::Tidy::perltidy( | |
perltidyrc => \( do { local $/ = <DATA> } ), | |
prefilter => sub { | |
no warnings; |
View pw-84-matrix.pl
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 strict; | |
use warnings; | |
package Weekly84 { | |
use Zydeco; | |
class Matrix { | |
# public required attribute | |
has cells! ( type => ArrayRef[ArrayRef[Bool, 1], 1] ); |
NewerOlder