Skip to content

Instantly share code, notes, and snippets.

View exodist's full-sized avatar

Chad Granum exodist

View GitHub Profile
@exodist
exodist / test.pl
Created October 22, 2015 18:29
LOL
use strict;
use warnings;
package aaa;
sub foo { print "A\n" }
package aab;
sub foo { print "B\n" }
package main;
@exodist
exodist / test.pl
Created October 22, 2015 15:43
Sub::Uplevel vs goto
use strict;
use warnings;
package uplevel;
use Sub::Uplevel;
use Carp qw/cluck/;
#line 10
sub a { cluck "XXX" };
sub b { a('a') }
@exodist
exodist / clever.pl
Created October 22, 2015 05:21
What will this print? clever!
use strict;
use warnings;
my $count = 4;
while (1) {
print "loop: " . (5 - $count) . "\n";
no warnings 'void';
$count-- xor next if $count;
@exodist
exodist / test.pl
Created October 21, 2015 20:50
pure perl Sub::Name, mostly
use strict;
use warnings;
use Carp qw/longmess/;
use B;
my @STASH;
sub set_sub_name {
my ($name, $sub) = @_;
use strict;
use warnings;
use B;
sub simple {
print "A";
use strict;
use warnings;
use Test::More;
use Scalar::Util qw/reftype/;
sub redact {
my ($thing, $replace, @fix) = @_;
my %seen;
my @stack = ($thing);
while (@stack) {
use Test::Stream -V1, Compare => '*';
is(
{ a => 'foo', b => 'bar' },
hash {
field a => match qr/fox/;
field b => match qr/box/;
},
"Sample"
);
commit 9f39a706c009646a5876cf205c8b6c13b7445e28
Author: Chad Granum <[email protected]>
Date: Sat Sep 26 22:40:04 2015 -0700
Capabilities: detect bad 5.10.0 threads
diff --git a/lib/Test/Stream/Capabilities.pm b/lib/Test/Stream/Capabilities.pm
index 4e65ff9..27b8cae 100644
--- a/lib/Test/Stream/Capabilities.pm
+++ b/lib/Test/Stream/Capabilities.pm
$ tracepath -m200 bad.horse
[...]
8: t00.nycmc1.ny.us.sn11.net 101.570ms
9: bad.horse 102.077ms asymm 12
10: bad.horse 106.139ms asymm 12
11: bad.horse 108.322ms asymm 12
12: bad.horse 116.249ms
13: he.rides.across.the.nation 121.157ms
14: the.thoroughbred.of.sin 126.335ms
15: he.got.the.application 131.509ms
use strict;
use warnings;
sub do_it {
my $x = 1;
$x++ while caller($x);
print "Doin' it (Depth: $x)\n";
eval "END { do_it; exit }; 1 "|| die $@;
}