On Feb 27, Stuart Clark said:

>Hi All,
>
>How do i gather an array of data from a line which has no delimiters.
>The data is put into positions relative to the start of the line.

>#string 1 will be position 1-5 on the line
>#string 2 will be position 6-15 on the line
>#string 3 will be position 16-23 on the line
>#string 4 will be position 24-28 on the line
>#string 5 will be position 29-34 on the line

Sounds like a job for unpack().

  @fields = unpack "A5 A10 A8 A5 A6", $string;

You can come up with a function to go from the list (5,15,23,28,34) to the
format string "A5 A10 A8 A5 A6" pretty easily.  (Hint: subtraction.)

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to