Skip to content

Instantly share code, notes, and snippets.

View dur-randir's full-sized avatar

Sergey Aleynikov dur-randir

View GitHub Profile
package Foo;
use overload '&{}' => sub { \&call_cplusplus };
sub call_cplusplus { warn 42 }
sub new {return bless sub {}, shift}
package main;
my $obj = Foo->new;
use Scalar::Util qw/reftype/;
warn reftype $obj;
$obj->();
SeaBIOS (version rel-1.8.0-48-g1d9e87b-dirty-20180223_211656-fangorn)
No Xen hypervisor found.
enabling shadow ram
Running on QEMU (q35)
Running on KVM
Add to e820 map: 00000000 20000000 1
Add to e820 map: fffc0000 00040000 2
RamSize: 0x20000000 [cmos]
malloc preinit
Add to e820 map: 000a0000 00050000 -1
SeaBIOS (version rel-1.8.0-48-g1d9e87b-dirty-20180223_211656-fangorn)
No Xen hypervisor found.
enabling shadow ram
Running on QEMU (q35)
Running on KVM
Add to e820 map: 00000000 20000000 1
Add to e820 map: fffc0000 00040000 2
RamSize: 0x20000000 [cmos]
malloc preinit
Add to e820 map: 000a0000 00050000 -1
use ExtUtils::MakeMaker;
use ExtUtils::Depends;
my $package = ExtUtils::Depends->new('Foo', 'XS::Object::Magic');
WriteMakefile(
NAME => 'Foo',
$package->get_makefile_vars(),
);
perl -e 'sub foo {warn 42} $glob = $main::{foo}; $glob->(); *$glob{CODE}->()'
perl -e 'our $foo; sub foo {warn 42} $glob = $main::{foo}; $glob->(); *$glob{CODE}->()'
package Z;
use Devel::Peek ();
use overload "+"=>sub {42};
die "fail" unless 42 == bless({}) + 1;
Devel::Peek::Dump \%Z::;
use Inline C => <<END;
void foo(SV* targ) {
if (!SvOK(targ)) return;
if (SvROK(targ)) targ = SvRV(targ);
TEST_JOBS 16 32 72
blead 2:34 2:44 2:55
khw-harness 2:48 2:31 3:09
use Devel::Peek;
#use Data::Printer use_prototypes => 0, return_value => 'pass';
#use Data::Printer use_prototypes => 1, return_value => 'pass';
my $foo = \*STDIN;
Dump(p $foo);
with use_prototypes => 0:
*main::STDIN (read/write, layers: unix perlio)
SV = PVGV(0x7f8e3a91aea0) at 0x7f8e3aa25f30
use mro 'c3';
package Foo {
our @ISA = qw/Bar/;
use Sub::Name qw/subname/;
*foo = \&Bar::foo;
subname bar => \&foo;
};
package Bar {