3 月 182019
 

Source: 不止一種方法去做一件事

不止一種方法去做一件事There's more than one way to do itTMTOWTDITIMTOWTDI,發音為「Tim Toady」)是一條Perl俗語。這個語言本身就是用這個「不要教程式設計師如何編程」的主意設計的。這使得很容易可以寫出極度雜亂的程序,但是,根據支持者對這個俗語的理解,這也可以很容易地寫出簡潔的語句。

Continue reading »
7 月 102008
 

Perl trim function to strip whitespace from a string

Perl does not have a built-in trim function. Use the subroutine below to trim whitespace (spaces and tabs) from the beginning and end of a string in Perl. This function is directly based on the Perl FAQ entry, How do I strip blank space from the beginning/end of a string?. The ltrim and rtrim functions can trim leading or trailing whitespace.
Continue reading »