- or download this
my $coderef = sub {shift;};
my $val=$coderef->("Hello from down under");
...
}
&doit($val);
- or download this
my $coderef = sub {shift;};
sub doit{
print shift, $/;
}
&doit($coderef->("Hello from down under"));
- or download this
#Closured.pm
#!/usr/local/bin/perl -cw
...
&{$_[0]};
}
1;
- or download this
#using the Closured class...
use strict;
...
my $object = Closured->new("Hisham"); #try to feed a constructor direc
+tly.
print $object,$/; #the constructor retruns a code ref.
print $object->name("BioHisham"), "\n"; #Feed via an instance method
- or download this
#Output
Closured=CODE(0x18449ac)
BioHisham
- or download this