/usr/share/doc/libffi-platypus-perl/examples/closure.pl is in libffi-platypus-perl 0.45-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | use strict;
use warnings;
use FFI::Platypus;
my $ffi = FFI::Platypus->new;
$ffi->lib('./closure.so');
$ffi->type('(int)->int' => 'closure_t');
$ffi->attach(set_closure => ['closure_t'] => 'void');
$ffi->attach(call_closure => ['int'] => 'int');
my $closure1 = $ffi->closure(sub { $_[0] * 2 });
set_closure($closure1);
print call_closure(2), "\n"; # prints "4"
my $closure2 = $ffi->closure(sub { $_[0] * 4 });
set_closure($closure2);
print call_closure(2), "\n"; # prints "8"
|