Well, closures are just a special case of code ref, so the answer is yes. Both Data::Dumper and Data::Dump::Streamer can dump closures as they both can dump code references.
Incidentally this is one of those common misnomers that seem to pop up in Perl circles. Theres a habit of calling "annoymous code refs" as closures, because normally its not obvious that named subroutines can also be closures. And from a perl point of view you never actually interact with a subroutine (beyond calling it) except by reference. So from a given piece of codes POV there is no difference between a "closure", an "anonymous subroutine that isnt a closure" or a "reference to a named subroutine". They are all just references to a CODE object. This holds true for all of perls types pretty much. There is no difference between a "reference to a named array" and an "anonymous array" etc etc.
sub Foo {print "Foo!\n"} # named subroutine / non-closure
my $foo= sub { print "Bar!\n"}; # anonymous / non-closure
my $bar= sub { $foo->() }; # anonymous / closure
sub FooBar { $bar->() } # named subroutine / closure
sub takes_a_callback {
my $callback=shift;
$callback->();
}
takes_a_callback($_) foreach \&Foo,$foo,$bar,\&FooBar;
In the above case takes_a_callback() can't tell if it what it recieves is a closure or not, nor if its a named subroutine. All it knows that if the object actually is a code ref it will execute it with no arguments. If its isnt a code ref it'll die.
HTH
---
demerphq
First they ignore you, then they laugh at you, then they fight you, then you win.
-- Gandhi
|