On the topic of trying to promote readable, modern Perl, I just happened to come across this in the wikipedia article on "Function Objects": <a href="http://en.wikipedia.org/wiki/Function_object#In_Perl">http://en.wikipedia.org/wiki/Function_object#In_Perl</a>. It's a terrible, terrible ambassador for Perl, and I think actually misses the point of the article. If you compare the Perl code with even the Javascript code it's downright embarrassing.<div>
<br></div><div>I'm going to mirror the Javascript example and rewriting the Perl code as follows, anybody have any comments on this?</div><div><br></div><div>In Perl, functions are first class objects.  Perl also supports closures.</div>
<div><br></div><div><div>sub make_accumulator {</div><div>    my $current = shift;</div><div>    return sub { return $current += shift };</div><div>}</div><div><br></div><div>$acc1 = make_accumulator(42);</div><div>$acc2 = make_accumulator(9000);</div>
<div><br></div><div>print $acc1->(3),   "\n";    # prints '45'</div><div>print $acc1->(3),   "\n";    # prints '48'</div><div>print $acc2->(542), "\n";    # prints '9542'</div>
</div><div><br></div>