On May 22, Peter Cline said:

>>   @parts = split ' ', "this  and that";
>>   { local $" = ") (";  print "(@parts)"; }
>>   # (this) (and) (that)
>
>Will the ") (" assign any amount of space to the list separator?
>This is interesting.  I haven't encountered this syntax before.

Using split ' ' is magical.  First, it removes leading and trailing
whitespace from the string, and THEN it splits like /\s+/.

  @parts = split ' ', "    a   b c   def  ";
  print scalar @parts;     # 4
  print join ",", @parts;  # a,b,c,def

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
Are you a Monk?  http://www.perlmonks.com/     http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc.     http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter.         Brother #734
** I need a publisher for my book "Learning Perl's Regular Expressions" **

Reply via email to