Hi again,
I am having some difficulty getting the output to actually contain 80 charachers. The code section show my code, and text section is as follows:
The first line is a portion of the 4 Mb text file I need formated. The remainder is what it SHOULD look like, but it does not. The output turns out like this :
<Text>
ISA*00* *00* *28*9000000454 *ZZ*J00370
*070926*0342*U*00401*000489661*0*P*:~
<Text>
the '~' must remain and in Notepad there is a C/R after each '~"
#! / usr/bin/perl -w
use Text::Wrap qw(wrap);
#
#
use POSIX 'strftime';
$name = $ARGV[0];
$name1 = $ARGV[1];
#
# strip out all Carriage Returns
#
# Process the file by replacing each tilde (~) with a carriage return
+/ line feed and
# save the file in the correct file format.
#
#
open (INFILE, "<$name");
open (OUTFILE, ">$name1");
$Text::Wrap::columns = 80;
while (my $row = <INFILE>) {
print OUTFILE wrap('','',$row) ;
}
close (INFILE);
close (OUTFILE);
ISA*00* *00* *28*9000000454 *ZZ*J00370 *
+070926*0342*U*00401*000489661*0*P*:~
GS*HP*9000000454*J00370*20070926*03421826*489660*X*004010X091A1~
ST*835*489662~
BPR*I*6519.36*C*ACH*CCP*01*075906003*DA*0000194917*1351840597*00454
+ *01*021000021*DA*304677450*20070926~
TRN*1*EFT2545408*13
ISA*00* *00* *28*9000000454 *ZZ*J00370 *
+070926*0
342*U*00401*000489661*0*P*:~
GS*HP*9000000454*J00370*20070926*03421826*489660*
X*004010X091A1~
ST*835*489662~
BPR*I*6519.36*C*ACH*CCP*01*075906003*DA*00001949
17*1351840597*00454 *01*021000021*DA*304677450*20070926~
TRN*1*EFT2545408*13
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.