http://www.perlmonks.org?node_id=950904


in reply to Re: How many loops are there in Perl?
in thread How many loops are there in Perl?

In the spirit of your map and grep examples, here's one using sort...

perl -E'join("|", sort {do{say "Inside sort loop"} and $a <=> $b} 3,1, +2)'

Works in 5.10.1, but the Perl sorting algorithm has been known to change from version to version. Note that the join does seem to be needed to avoid Perl optimizing away the sort.