in reply to Dynamic Subroutines?
Then you call it using the -> notation:sub create_subroutine_to_return_constant { my ($constant) = @_; my $newsub = sub { return $constant }; return $newsub; }
This technique is a lot more interesting than the example I showed. But I didn't want to give too much information at once.my $PI = create_subroutine_to_return_constant(3); $z = $PI->(); # returns 3
Perhaps you could say a little more about what you are trying to accomplish here.
|
|---|