in reply to How does this code work? (from "Perl is Unix")
Just for completeness’ sake, that strip function code is a condensed syntactic (near) equivalent of this function:
sub strip { my @r = @_; for ( @r ) { s/\A\s+//; s/\s+\z//; } return @r; }
But I didn’t want to spend 6 lines on a routine that is completely incidental to the main point of the code, and which I put there only to emulate the exact behaviour of the Ruby and Python counterparts. If it were in a module with string functions, I would write it in the long-hand form. Programming is writing and code is literature. Sometimes you need to linger on the details and sometimes they would only derail the pacing.
Makeshifts last the longest.
In Section
Seekers of Perl Wisdom