Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Check21/X9.37 text extractor

by jwkrahn (Monsignor)
on Jul 31, 2009 at 23:28 UTC ( #785026=note: print w/ replies, xml ) Need Help??


in reply to Check21/X9.37 text extractor

open(FILE,'<',$ARGV[0]) or die 'Error opening input file';

You should include the $! variable in the error message so you know why it failed to open:

open FILE, '<:raw', $ARGV[0] or die "Error opening '$ARGV[0]' $!";


while (read (FILE,$_,4)) {

Just because you ask for 4 bytes that does not mean the operating system will give you 4 bytes.   You should verify that you actually received 4 bytes.


  read (FILE,$_,$rec_len);

Same thing here.


    if ($tiff_flag) {

The only place that you assign any value to $tiff_flag is at the beginning where you set it to 0 so it will always be false.

  or die "Can't create image file";

You should include the $! variable in the error message so you know why it failed to open.


Comment on Re: Check21/X9.37 text extractor
Select or Download Code
Re^2: Check21/X9.37 text extractor
by ambrus (Abbot) on Aug 01, 2009 at 12:07 UTC
    You should include the $! variable in the error message so you know why it failed to open:

    There's no need to add that to every statement for a quick script unless you do expect to run on that error often. You can figure out the error code after the fact as perl's die statement helpfully sets the exit code to $! % 256 || 1, so eg. if you print the exit code from the shell after you get this error message and you find that it's 2 you can be sure the error was ENOENT (No such file or directory). (The higher error codes are platform-dependent, but you can still find out the strerror message for them with eg. perl -we 'die($!=2)')

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2014-08-01 04:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (256 votes), past polls