in reply to Re: Functions in Perl
in thread Functions in Perl
That doesn't do what Gunth's OO code does. His code makes an object that holds the counter that keeps increasing for every call to &print. So the second time it continues where it stopped the first time. Your code has the equivalent result of throwing away the object after each use, i.e. Example::->new->(...).
My closure example below shows the equivalent of the OO example.
ihb
|
|---|