Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cmcl2!hsdndev!rice!uw-beaver!milton!djo7613@milton.u.washington.edu From: djo7613@milton.u.washington.edu (Dick O'Connor) Newsgroups: comp.lang.perl Subject: Splitting by character count in perl? Message-ID: <17806@milton.u.washington.edu> Date: 6 Mar 91 07:23:13 GMT Sender: djo7613@milton.u.washington.edu Distribution: usa Organization: University of Washington, Seattle Lines: 25 In order to follow an ancient bitpath left over from the days of HASP and card punch queues, I need to split a file of 150 character lines into a file of lines 80 characters wide or less. Back when our Cyber was active, we did this with a simple Fortran program; now I've got Ultrix and even perl (!) at my disposal, and this problem cries out for a filter, not a pgm. Our old program copied the first 78 characters on a line to the output file after prepending and appending the character 'A'. Characters 79-150 were written to line 2 of the output file with prepended and appended 'B'. A simple routine glued things back together at the other end. Trouble is, I'm enough of a novice that I can't see the simple Unix way. All of the utilities I've looked at would be a lot happier if I could move entire lines or fields. But this is a file of typical scientific data; no tabs, blanks may or may not separate fields depending on the width of the (right-justified) number in that field, and an overall adherence to a pre-defined "format." After searching the perl man page, I'm stuck. I keep thinking split can do what I need, but the examples don't make it clear. I'd prefer a perl solution to one using "other" utilities; any takers? It's that or I use f77, and we wouldn't want to do that, would we?? :) Thanks! "Moby" Dick O'Connor djo7613@u.washington.edu Washington Department of Fisheries *I brake for salmonids*