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; | |
no warnings 'experimental'; | |
use feature 'lexical_subs'; # my sub, experimental in perl 5.18 | |
use feature 'say'; | |
use utf8; | |
package AA; | |
sub new |
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/perl | |
# mkdir -p ~/.gittemplate/hooks | |
# git config --global init.templatedir ~/.gittemplate | |
# | |
# Save this script as ~/.gittemplate/hooks/post-checkout | |
use 5.010; | |
use strict; | |
use warnings; |
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 5.010; | |
use strict; | |
use warnings; | |
use Module::CoreList 2.99; | |
use Getopt::Long; | |
my $verbose; # --verbose |
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 | |
# List of core-only modules: modules that are bundled with perl, and not on CPAN | |
# Unfortunately this list includes modules that are distributed on CPAN but have | |
# been hidden from PAUSE indexing. | |
# Example: Locale::Codes::Country_Codes | |
use 5.010; | |
use strict; | |
use warnings; |
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
# Just once | |
test -f ~/bin/traceuse-modules.sed || echo 's/^ *[1-9][0-9]*\. *\([A-Za-z][^ ,/]*\) .*$/\1/p' > ~/bin/traceuse-modules.sed | |
# Use Devel::TraceUse to find modules used in the Dist::Zilla build | |
perl -d:TraceUse=output:x.txt -S dzil listdeps > /dev/null | |
# Extract modules list from Devel::TraceUse output and upgrade them | |
sed -n -f ~/bin/traceuse-modules.sed x.txt | sort | xargs cpan |
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; use 5.014; | |
select(STDOUT); $| = 1; # DO NOT REMOVE | |
# The code below will read all the game information for you. | |
# On each game turn, information will be available on the standard input, you will be sent: | |
# -> the total number of visible enemies | |
# -> for each enemy, its name and distance from you | |
# The system will wait for you to write an enemy name on the standard output. | |
# Once you have designated a target: | |
# -> the cannon will shoot |
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 | |
# System perl on Debian is threaded. | |
# Here is how to try to build a compatible one with plenv: | |
# plenv install 5.20.1 --as=5.20.1-thr -Dusethread | |
use Config; | |
use File::Path 'make_path'; | |
my $errors = 0; |
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
// A point class must be immutable | |
class Point | |
{ | |
public final double x; | |
public final double y; | |
public Point(double x, double y) | |
{ | |
this.x = x; |
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; | |
use Test::More tests => 1; | |
use B; | |
my $x = \(my $y); | |
# In newer TB, the reference to note's argument is kept and breaks the following test | |
note $x; | |
is(B::svref_2object($x)->REFCNT, 2, "refcnt=2"); |
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 | |
# Dynamically patch cpanm | |
# Alternative implementation to: | |
# https://gist.github.com/kentfredric/ce1df3e7e509e071b63d | |
use strict; | |
use 5.010001; | |
use warnings; | |
use Scalar::Util qw(blessed); |
OlderNewer