Skip to content

Instantly share code, notes, and snippets.

View schwern's full-sized avatar

Michael G. Schwern schwern

View GitHub Profile
@schwern
schwern / gist:3215341
Created July 31, 2012 09:06
Operator overload in Perl
#!/usr/bin/env perl
use strict;
use warnings;
use File::Basename;
use lib dirname(__FILE__);
{
package GS_URI;
#0 0x00007fff871880f0 in __wait4 ()
#1 0x00000001001aaa48 in signal_handler ()
#2 <signal handler called>
#3 0x00000001001c2873 in sharedsv_elem_mg_FETCH ()
#4 0x000000010007bc0b in Perl_mg_get ()
#5 0x0000000100097844 in Perl_sv_setsv_flags ()
#6 0x00000001000949dc in Perl_sv_mortalcopy ()
#7 0x00000001000899e1 in Perl_pp_helem ()
#8 0x0000000100084c16 in Perl_runops_standard ()
#9 0x0000000100017e68 in Perl_call_sv ()
# Individually change to any of the "no segfault" versions and it works.
use strict;
use warnings;
use threads;
use threads::shared;
use TB2::TestState;
use strict;
use warnings;
use Test::More;
pass("Before fork");
my $tb = Test::More->builder;
# Don't use numbers, so test synchronization between processes is not
@schwern
schwern / gist:1403823
Created November 29, 2011 07:12
fork.t
use strict;
use warnings;
use Test::More tests => 4;
pass("Before fork");
my $tb = Test::More->builder;
my $pid = fork;
use strict;
use warnings;
# A hard coded plan so the parent process does not need to count
use Test::More tests => 4;
pass("Before fork");
my $tb = Test::More->builder;
@schwern
schwern / gist:1283112
Created October 13, 2011 01:33
Output from 1281618
1..1
test
not ok 1
# Failed test at /Users/schwern/tmp/test.plx line 45.
# An error occurred while using eq:
# ------------------------------------
# Cannot compare MyTest with "test" at /Users/schwern/tmp/test.plx line 21
# MyTest::_operator_cmp('MyTest=HASH(0x100803c68)', 'test', '') called at (eval in cmp_ok) /Users/schwern/tmp/test.plx line 45
# eval '
# #line 45 "(eval in cmp_ok) /Users/schwern/tmp/test.plx"
@schwern
schwern / gist:1239816
Created September 24, 2011 20:27
Profile MXMS empty method call
BEGIN { DB::disable_profile() }
{
package Foo;
use Moose;
use MooseX::Method::Signatures;
method empty {}
}
@schwern
schwern / gist:1238797
Created September 24, 2011 00:57
MooseX::Method::Signatures vs Method::Signatures vs PurePerl
{
package WithMXMS;
use Moose;
use MooseX::Method::Signatures;
method gndn {}
}
@schwern
schwern / gist:1238683
Created September 23, 2011 23:05
Demonstrate lexical pragma nature of bundles with Method::Signatures
# Simulate a bundle module
BEGIN {
package Bundle;
use parent qw(Method::Signatures);
}
# Simulate a user of that bundle
package Bar;
{