3月 02

[荐] 《Beginning Perl》 and “Understand References Today”

……【阅读全文】

12月 09

在Perl中高效sort——Schwartzian变换

In computer science, the Schwartzian transform is a Perl programming idiom used to improve the efficiency of sorting a list of items. This idiom is appropriate for comparison-based sorting when the ordering is actually based on the ordering of a certain property (the key) of the elements, where computing that property is an intensive operation that should be performed a minimal number of times. The Schwartzian Transform is notable in that it does not use named temporary arrays.……【阅读全文】

12月 09

在Perl中高效sort——Orcish算法

The Orcish Maneuver (invented by Joseph N. Hall [8]) eliminates the preprocessing pass over the data, which might save keeping a copy of the data if they are being read directly from a file. It does the sortkey extraction only once per record, as it checks the hash to see if it was done before. The test and storage of the sortkey is done with the ||= operator (short-circuit or-assignment), which will evaluate and assign the expression on the right to the lvalue on the left, if the lvalue is false. The name “orcish” is a pun on “or-cache”. The full statement in the sortsub looks like this:……【阅读全文】