$ cat ./coderref #!/usr/bin/perl package CodeRef; { use Object::InsideOut; my @code :Field :Std( Name => 'code', Private => 1 ) :Arg(Name => 'code', Mand =>1 ) :Type(CODE_REF); 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 ); $ ./coderef OIO::Args error: Bad value for initializer 'code': CODE(0x9d16cc0) Usage: Initializer 'code' for class 'CodeRef' must be an object or ref of type 'CODE_REF' Package: main File: coderef Line: 35 Trace begun at coderef line 35