vineet2004 has asked for the wisdom of the Perl Monks concerning the following question:
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Empty output file with Red Hat
by davido (Cardinal) on Dec 26, 2006 at 05:11 UTC | |
Does the script fail silently, or do you get an error message? And if it fails silently, do you suppose you might be able to add some error checking to the script so that it will complain if something goes wrong? You're going to need to uncover and report to us some clues before anyone can meaningfully help you to ascertain what's wrong. Also, is there any way you can post relevant portions of the code, or at least a small example script that replicates the failure? Otherwise, we're only going to be able to guess, and you don't really want to settle for guesses when by providing a little more background you could get accurate answers. Dave | [reply] |
by vineet2004 (Initiate) on Dec 26, 2006 at 05:19 UTC | |
20061226 Janitored by Corion: Added code tags, as per Writeup Formatting Tips | [reply] [d/l] |
by andyford (Curate) on Dec 26, 2006 at 16:36 UTC | |
To avoid puzzling problems with missing data files, test your input with something along these lines: Then you'll know when you've got no data file to work on. Also suggested is the use of "use warnings" and "use strict" at the beginning of nearly every Perl program.
non-Perl: Andy Ford | [reply] [d/l] |
| |
|
Re: Empty output file with Red Hat
by hesco (Deacon) on Dec 27, 2006 at 08:31 UTC | |
Then save your changes and run your script. See if that worked. Did it give you your expected output? If not, debug that. If so, uncomment a small block of code and copy your debug statement just below it. Run your test again. Feel free to comment out debug statements earlier in the script, if they have told you what they need to. But don't delete them, As your script matures, they may get reworked as log statements and be used again. As you copy your debug line down past tested and working code, you can make the debug output more informative, say by writing it this way:
Have you examined the logfile you are processing? Does it contain any lines matched by your regex? If you run this file without redirecting its output, do you see any feedback in the console? You would likely learn quite a bit about your script were you to write conditions to handle exceptions. Robust code includes lots of conditional paths that the programmer expects will never be taken by legitimate data in a production environment. But coding that exception handling will help you see where you perhaps made bad assumptions about what your code is actually doing. A properly handled exception might recover so the script need not terminate. It could add useful debugging information to a log file. At the very least it could die in a loud and descriptive way. -- Hugh
if( $lal && $lol ) { $life++; }
| [reply] [d/l] [select] |