# -*- Perl -*-
package Foo;
use strict;
use warnings;
sub new { bless [], shift }
sub warn { shift; warn "[", __PACKAGE__, "] ", @_ }
sub do_cb {
my ($self, $cb)=@_;
$self->$cb;
}
1;
__END__
####
#!/usr/bin/perl
use strict;
use warnings;
use Foo;
my $f=Foo->new;
$f->do_cb(sub {
my $caller=shift;
$caller->warn("no good for me\n");
});
__END__
####
warn $caller "no good for me\n";