Sample Text
999999999999 + XXXXXXXXXX
When I read in the text line by line, I can check for the 014 shift out ASCII character however when I use the print OUT $line the ASCII character is wrong. here is my code
#!/usr/bin/perl use CGI qw(:standard); open(INFO, "testdoc.txt"); print header(); print start_html(); my @record; my %hash; my $true = 0; $i =0; my $FEI; my $pack; ($sec,$min,$hour,$mday,$mon,$year,$wday, $yday,$isdst)=localtime(time); #printf "%4d-%02d-%02d %02d:%02d:%02d\n", $year+1900,$mon+1,$mday,$hou +r,$min,$sec; open (OUT, '>OUTPUT.txt'); while ($line = <INFO>){ # print $line . "<BR>"; #check each character of the line for a page break for (split//,$line) { $test = sprintf "\%3o\n", ord $_; if ($test == 14) { # WE HAVE FOUND A NEW PAGE $true = 1; $hash->{$i} = printf("$line %d",$_); $i++; # store next 8 lines in a hash } } if ($true == 1){ $hash->{$i} = $line; print $hash->{i} . "<br>"; if ($i == 9){ if ($hash->{9} =~ /4\d{8}/ig) { $hash->{2} = " + Heart Hospital\n"; } if ($hash->{2} =~ /Heart Hospital/){ $FEI = $hash->{6}; #print $FEI . "<br>"; switch the F +EI to what Doris recommends $FEI =~ s/350593390/261766835/; $hash->{6} = $FEI; } #print OUT $hash->{1};# . "\n"; print OUT $hash->{2};# . "\n"; print OUT $hash->{3};# . "\n"; print OUT $hash->{4};# . "\n"; print OUT $hash->{5};# . "\n"; print OUT $hash->{6};# . "\n"; print OUT $hash->{7};# . "\n"; print OUT $hash->{8};# . "\n"; print OUT $hash->{9};# . "\n"; #print $hash->{1} . "1<br>"; print $hash->{2} . "2<br>"; print $hash->{3} . "3<br>"; print $hash->{4} . "4<br>"; print $hash->{5} . "5<br>"; print $hash->{6} . "6<br>"; print $hash->{7} . "7<br>"; print $hash->{8} . "8<br>"; print $hash->{9} . "9<br>"; $i=0; $true=0; $hash->{1} = ""; $hash->{2} = ""; $hash->{3} = ""; $hash->{4} = ""; $hash->{5} = ""; $hash->{6} = ""; $hash->{7} = ""; $hash->{8} = ""; $hash->{9} = ""; } elsif ($line =~/TOTALS/){ print OUT $line; } elsif ($line =~/END OF REPORT/){ print OUT $line; } else { $i++ } }else{ print OUT $line } } #end while close OUT; print end_html();

In reply to Re^4: ASCII insert after read by Anonymous Monk
in thread ASCII insert after read by monkjeff

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.