kaasboy has asked for the wisdom of the Perl Monks concerning the following question:

Hello Wise Monks

I have a question about some scripting that a programmer (who has now left) at my work did for a report I run. I run two reports get the phone performace stats of our agents. These are saved as .csv files into a folder and the Perl program runs every minute, it then spits out a 3rd giving me a condensed version of the two with some more specific info. We recently upgraded our phone reporting system and now the Perl report won't run. I am producing the 2 .csv files but now when I run it the output txt says:

"[FATAL] (3) Encountered line of unknown length (11)"

I have asked the IT guys here what could be causing the problem but no-one knows Perl. I got a copy of the script and this is the line that seems to relate to the error message:

print "[DEBUG] ($.) Call Length det='$detail' ($dh:$dm:$ds)\n" if $DEB +UG; } else { # TODO : Might want to issue an alert and solder on! safedie "[FATAL] ($.) Encountered line of unknown length (",$#line + 1 +,")";

Can you please advise what Perl is telling me about the .csv files? I have looked over copies of ones that worked and ones that don't and I can't see what could be causing the problem.

Thanks very much for any wisdom you can offer!

20071129 Janitored by Corion: Added formatting, code tags, as per Writeup Formatting Tips

Replies are listed 'Best First'.
Re: do not understand [Fatal] message
by graff (Chancellor) on Nov 26, 2007 at 04:50 UTC
    You probably would need to show us a little more of the code, and you would have to put the code between <code> and </code> tags, so it will be easier for us to see it. It would also help a lot if you could tell us what modules are being used in the script -- look for lines that begin with "use " (if any), and show those to us.

    For that matter, if the script as a whole is not too big (and if posting it in public here will not get you into trouble), show us the whole thing. (Anything over 150 lines is probably "too big", and you would have to figure out how to show us just the relevant parts -- for instance, if the line with the error is inside a subroutine, maybe you could show us the whole sub block, and the line(s) elsewhere in the code where the subroutine is called.)

    Offhand, it sounds like a case where the new reporting system has more fields than the old one did, or maybe (ugh) it uses different numbers of fields on some records. (Or maybe there is a problem with the new files, and this program would not fail if the files were actually okay).

      Thanks all for your answers. The script is too big to post here but I think you may be right about the new reporting system having changed it's fields. I'm waiting to hear back from the vendor's developers to see if they can tell me what differences there are between the old and new versions. Cheers K
Re: do not understand [Fatal] message
by localfilmmaker (Novice) on Nov 26, 2007 at 05:07 UTC
    There is a key piece of information missing from your post. You pasted this in your question:
    } else { # TODO ... }
    However, we didn't get the if (...) { that began that section of code. I agree with graff, but just wanted to point out that one vital missing piece as well.
Re: do not understand [Fatal] message
by narainhere (Monk) on Nov 26, 2007 at 08:56 UTC
    Reading on you lines, your code should look something like
    if (condition){ print "DEBUG ($.) Call Length det='$detail' ($dh:$dm:$ds)\n" if $DEBUG +; } else { # TODO : Might want to issue an alert and solder on! safedie print "FATAL ($.) Encountered line of unknown length (",$#line + 1,")" +; }
    So that means If the condition is true and if DEBUG mode is on then
    print "DEBUG ($.) Call Length det='$detail' ($dh:$dm:$ds)\n" if $DEBUG +;
    would be executed.
    Looking at your o/p, I guess the condition is failing.You should turn on-the DEBUG mode built in you script to get more details!

    The world is so big for any individual to conquer

Re: do not understand [Fatal] message
by nadeem55 (Initiate) on Nov 26, 2007 at 07:24 UTC
    I think that the problem is with your new created csv files. These will be not same as before.