home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / perl / 4857 < prev    next >
Encoding:
Text File  |  1992-07-21  |  1.5 KB  |  41 lines

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!til!til!tanaka
  3. From: tanaka@til.til.com (Yokichi Tanaka)
  4. Subject: Re: Bug in split(/\W+/) with "*" or "+" in input. 
  5. Message-ID: <1992Jul21.235848.24033@til.til.com>
  6. Sender: tanaka@til (Yokichi Tanaka)
  7. Nntp-Posting-Host: til
  8. Organization: Togai InfraLogic, Inc.
  9. References: <1992Jul17.235506.25157@newsgate.sps.mot.com> <1992Jul18.052238.3430@news.belwue.de>
  10. Date: Tue, 21 Jul 1992 23:58:48 GMT
  11. Lines: 28
  12.  
  13. In article <1992Jul18.052238.3430@news.belwue.de>, wschmidt@commix (Wolfram Schmidt) writes:
  14. |> In article <1992Jul17.235506.25157@newsgate.sps.mot.com> dichter@chdasic.sps.mot.com (Carl Dichter) writes:
  15. |> >There seems to be a bug in split, when using repeating whitespace as separator,
  16. |> >and input data contains apostrophes or plus signs.
  17. |> >
  18. |> >    ($pt1, $pt2, $pt3, $pt4, $pt5, $pt6) = split(/\W+/);
  19. |> 
  20. |> Use
  21. |>     ($pt1, $pt2, $pt3, $pt4, $pt5, $pt6) = split;
  22. |>     ($pt1, $pt2, $pt3, $pt4, $pt5, $pt6) = split(/\s+/);
  23. |>     ($pt1, $pt2, $pt3, $pt4, $pt5, $pt6) = split(/[ \t]+/);
  24. |> if you want to keep the newlines.
  25. |> 
  26. |> -Wolfram
  27. |> -- 
  28. |> wschmidt@iao.fhg.de Tel.: IAO: 0711/970-2431, Uni: 0711/121-3806
  29.  
  30. I always use:
  31.                ($x, $y) = split(' ');
  32.  
  33. Otherwise, leading whitespaces will result in a null first record (unless
  34. in cases where such behavior is desirable).
  35.  
  36. -- 
  37. Yokichi (Yoke) Tanaka      Togai InfraLogic, Inc.    "fuzzy"
  38. tanaka@til.com             Irvine, California, USA
  39. uunet!til!tanaka           714-975-8522
  40. "The more you drive, the less intelligent you are."
  41.