Howard Lowndes wrote:
OK, I have put some debugging into the Perl script and I have isolated the problem down to this piece of code (including my debug code):

For what it's worth, your debug code is better written as:

        my $lannet_err = $?;
        $lannet_err   .= ",$?";   # repeat this line as needed

    flock( PIPE_IN, LOCK_EX );

You'd improve the code quality a fair bit by changing the above line to:

        flock( PIPE_IN, LOCK_EX) or die "Failed to get lock: $!";

This would then tell you if your lock failed in some awful way, which it shouldn't...

my $lannet_err = $?;
    print PIPE_IN $input;
my $lannet_err = $lannet_err.",".$?;
    flock( PIPE_IN, LOCK_UN );

Since closing a file unlocks it for you, the above line isn't necessary and in fact is generally considered a mistake.

my $lannet_err = $lannet_err.",".$?;
    close(PIPE_IN);

This is the first time that $? is going to be meaningful. Closing the piped process ends the process and then the return status (including return code) is packed into $?. Looking at your results below this suggests that the process is returning 1 (rather than 0 which would signal success). What the 1 means depends on the process you're calling.

Also, what does "$? >> 8" do in the second array element, is it an 8 bitwise shift of 256, because it's output value is sprintf'd as "1"?

That's correct.

I was tempted to try fuzzyocr myself, but it failed our internal code review. :( If I have too much time on my hands anytime soon, I may send the original author a re-write.

        J
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to