>>>>> "JG" == Jim Gibson <jimsgib...@gmail.com> writes:

  >> i'm thinking about trying to include the whitespace cleanup in the
  >> s/// but i'm thinking it'll be an ugly piece of code i'll always have
  >> trouble understanding.

  JG> Use a separate regex instead of the join/split:

  JG>     $name =~ s/\s+/ /g;

normally i would agree, but his split also deleted leading and trailing
whitespace since split ' ' has that special side effect. 

  JG> Not ugly. Easy to understand: "substitute any substring of one or more
  JG> whitespace characters with a single space character".

even better and faster is to use tr/ //s (assuming only spaces and not
tabs/newlines, etc).

uri

-- 
Uri Guttman  ------  u...@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to