home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / perl / 7987 < prev    next >
Encoding:
Text File  |  1993-01-26  |  1.1 KB  |  33 lines

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!paladin.american.edu!howland.reston.ans.net!sol.ctr.columbia.edu!news.unomaha.edu!cwis!mfuhr
  3. From: mfuhr@cwis.unomaha.edu (Michael Fuhr)
  4. Subject: Re: Help Beginner
  5. Message-ID: <mfuhr.728022766@cwis>
  6. Sender: news@news.unomaha.edu (UNO Network News Server)
  7. Organization: University of Nebraska at Omaha
  8. References: <1993Jan25.224226.15695@digibd.com>
  9. Date: Tue, 26 Jan 1993 04:32:46 GMT
  10. Lines: 21
  11.  
  12. vince@digibd.com (Vince Mar) writes:
  13.  
  14. >If a line of text data contains vary fields, say range from 4 to 32, what is
  15. >the easiest way to get every field.  Any way similar to UNIX set command to
  16. >get $1..$n?  For example: a line contains "Thu Jan 21 1993  21:22:00", I 
  17. >suppose can use splite to know number of fields, but then how to use "for" or
  18.                  ^^^^^^
  19. >"while" loop to get each field assign to other variables?
  20.  
  21.  
  22. If I understand you, this is what you want:
  23.  
  24.     @fields = split(' ', $some_string);
  25.     foreach $field (@fields) {
  26.         # This loop iterates through each element in the array @fields,
  27.         # putting the value in $field.
  28.     }
  29.  
  30. --
  31. Michael Fuhr
  32. mfuhr@cwis.unomaha.edu
  33.