Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re: Check21/X9.37 text extractor

by Anonymous Monk
on Jun 16, 2015 at 20:08 UTC ( #1130701=note: print w/replies, xml ) Need Help??

in reply to Check21/X9.37 text extractor

Text part is viewed fine but tiff output cannot be read by any viewer. Paint, Fax reader, MS Image etc. Running on red hat Linux.
#!/usr/bin/perl -w use strict; use Encode; my $tiff_flag = 0; my $count = 0; open(FILE,'<',$ARGV[0]) or die 'Error opening input file'; binmode(FILE) or die 'Error setting binary mode on input file'; while (read (FILE,$_,4)) { my $rec_len = unpack("N",$_); die "Bad record length: $rec_len" unless ($rec_len > 0); read (FILE,$_,$rec_len); if (substr($_,0,2) eq "\xF5\xF2") { if ($tiff_flag) { $count++; open (TIFF, '>', $ARGV[0] . '_img' . sprintf(" +%04d",$count) . '.tiff') or die "Can't create image file"; binmode(TIFF) or die 'Error setting bina +ry mode on image file'; print TIFF substr($_,117); close TIFF; } $_ = substr($_,0,117 +); } print decode ('c +p1047', $_) . "\n"; } close FILE;

Code tags added by GrandFather

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1130701]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (7)
As of 2020-11-24 17:09 GMT
Find Nodes?
    Voting Booth?

    No recent polls found