At 8:19 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. $s = '123420010110010010101'; $s =~ /^(\d{4})(\d{2})(\d)(\d{14})/; #read the regular expressions $pin = $1; #man pages for more info $age = $2; $oth = $3; $misc = $4; print "$pin\t$age\t$oth\t$misc"; #"\t" = tab Or, on the whole file: open(FILE,$filename) || die "$!\n"; open(NEWFILE,">$newfilename") || die "$!\n"; while($s = <FILE>) { $s = '123420010110010010101'; $s =~ /^(\d{4})(\d{2})(\d)(\d{14})/; $pin = $1; $age = $2; $oth = $3; $misc = $4; print NEWFILE "$pin\t$age\t$oth\t$misc"; } close(NEWFILE); close(FILE); #======================================================================== I used to be a bartender at the Betty Ford Clinic. --Steven Wright Chris Nandor pudge@pobox.com PGP Key 0xB76E72AD http://pudge.net/