The Perl Toolchain Summit 2025 Needs You: You can help 🙏 Learn more

#!/usr/bin/env perl
use strict;
package Ping::Pong;
sub ping {
my $cb = pop;
$cb->(@_);
}
package main;
Ping::Pong->ping {
pass "pong";
my $caller = caller ;
is $caller, "Ping::Pong", "called from Ping::Pong";
};
Ping::Pong->ping(42) {
pass "pong";
my $caller = caller ;
is $caller, "Ping::Pong", "called from Ping::Pong";
};
my $pp = bless{}, "Ping::Pong";
$pp->ping(42) {
pass "pong";
my $caller = caller ;
is $caller, "Ping::Pong", "called from Ping::Pong";
};
done_testing;