#!/usr/bin/perl
package CodeRef;
use strict;
{
use Object::InsideOut;
warn sprintf "Using %s version %s",
'Object::InsideOut::VERSION',
$Object::InsideOut::VERSION
;
my @code :Field
:Std( Name => 'code', Private => 1 )
:Arg(Name => 'code', Mand =>1 )
:Type(CODE);
sub call() {
my $self = shift;
my $code = $self->get_code();
return $code->(@_);
}
}
1;
#=====
package main;
sub sum {
my $sum =0 ;
foreach my $num (@_) {
$sum += $num;
}
return $sum;
}
my $cref = CodeRef->new( code => \&sum );
__END__
Using Object::InsideOut::VERSION version 3.81 at tmp.pl line 9.
|