in reply to ascii manipulation in perl
I'm sure you'll be able to do what you need with Perl. Go out and get davorg's book Data Munging with Perl; it describes what you need to know to do this sort of thing. You can pick up the book on-line as a PDF for USD 18.50 from the publisher, but the printed copy is nice to have.
You will still need to think about how the records in your text file can be isolated from one another. For us to help you in this forum, we'd need to know whether the information after the three-digit record type is also significant, i.e. whether it also needs to be divided up into fields. From what you have told us already, you could use a function called unpack to do this:
#!/usr/bin/perl use strict; use warnings; my $template = 'A3A*'; # for unpack. it says you have some # ASCII data of a fixed length of 3, # and some more ASCII data until the # end of the record (record means 'li +ne' here) while (<DATA>) { my ($recordtype,$datastring) = unpack($template,$_); print "Record type: $recordtype\n$datastring\n\n" unless $recordtype + eq ''; } __DATA__ 090071905090405611071905001029842000281253P0223P0504011 80017 090071905090405611071905001029842000291253P0223P0504011 80007 03007190519912660000739900000026500 03007190519912660000839900000011500 040071905453901800xxxxxx x xxxxxxxx M4000 040071905453901806xxxxxx xxxxxxxx F4131 05007190545393434503187100 05007190545393963405187100 06007190545337000380199516129001399002650 06007190545337182980240356129999399013784 OUTPUT: Record type: 090 071905090405611071905001029842000281253P0223P0504011 80017 Record type: 090 071905090405611071905001029842000291253P0223P0504011 80007 Record type: 030 07190519912660000739900000026500 Record type: 030 07190519912660000839900000011500 Record type: 040 071905453901800xxxxxx x xxxxxxxx M4000 Record type: 040 071905453901806xxxxxx xxxxxxxx F4131 Record type: 050 07190545393434503187100 Record type: 050 07190545393963405187100 Record type: 060 07190545337000380199516129001399002650 Record type: 060 07190545337182980240356129999399013784
--
Allolex
|
|---|