[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Columns



At 2:19 PM +0100 on 1/2/97, Nico.Rozendaal@NP.UNIMAAS.NL wrote:


}Hallo,
}
}I have a (text) file with the following format:
}
}123420010110010010101  (and so on this way => )
}234531111101100101010
}678940000010010111010
}340151010101110101010
}and so on...
}
}Now let's say the first four characters are a PIN number,
}the following two characters the subject's age, and so on.
}How can I read such a file split in (fixed) columns ?
}I would like to insert tabs at the end of each field, creating
}a tab-delimited text file.

If I had to do this, I'd use a regular expression.  Reading in the file
line by line, I'd do something like

($pin,$age,....) = /(\d{4})(\d{2})..../;

and if I wanted to tab delimit the results and print them out, simply

print "$pin\t$age\t....\n";

}
}
}Thanks for your help, and a happy new year !
}
}# Nico Rozendaal,                                 #
}# University of Maastricht,                       #
}# Dept. of Psychiatry & Neuropsychology,          #
}# Maastricht, The Netherlands.                    #
}# e-mail: nico.rozendaal@np.unimaas.nl            #


--------
Paul J. Schinder
NASA Goddard Space Flight Center
Code 693
Greenbelt, MD 20770
schinder@pjstoaster.pg.md.us