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


in reply to Re (tilly) 1: New sections and move one
in thread New sections and move one

I'm using ActiveState for (yuk!) Windows cause that's my client platform. I have not been able to successfully install a CPAN module (as yet) unless ActiveState had it in it's PPM repository already. (I heard Brian Ingerson is on a leave of absence from ActiveState, when I called to complain that installing from the respository is throwing errors like never before, like missing dependent modules).

Please excuse me quickly throwing together some examples of what I mean. They were quickly tested, but I'm sure someone could make them better! What I'm suggesting is like the following examples. Someone new to Perl could use these right away on faith and learn what they mean after they "Saved the Day!" with their boss or client.

Update: Revised rtrim to use sexeger as suggested below!
sub rtrim { # Right trim spaces my @out=@_; for (@out) { $_ = reverse $_; s/^\s+//; $_ = reverse $_; } return wantarray ? @out : $out[0]; } sub ltrim { # Left trim spaces my @out=@_; for (@out) { s/^\s+//; } return wantarray ? @out : $out[0]; } sub trim { # Trim extra spaces from both left and right my @out=@_; for (@out) { s/^\s+//; s/\s+$//; } return wantarray ? @out : $out[0]; } sub trimall { # Trim all extra spaces from both left and right and middle my @out=@_; for (@out) { $_= join ' ',split; } return wantarray ? @out : $out[0]; }
Again, this could be the start of the "String related" category of the Perl Monks' "Subroutine Library." I don't think these kind of onezie subroutines would find a welcome home in CPAN as one routine per submission. If they were in a module, then I have the same 'discovery' and 'install' problems I have today. As onezies they would fail CPANTS for sure not being modules!

..:::::: aquacade ::::::..