in reply to printing to filehandles

Your code indenting is very difficult to follow. Try to use indenting-whitespace to make code more legible. perlstyle is a good guide to start with.

As for your problem, my recommendation is to check the return values of your various print statements like this:

print OUT "$1\n" or die "Couldn't print to OUT at line __LINE__:\n$!\n";

You may be surprised to see:

Couldn't print to OUT at line 23: Bad file descriptor

With warnings turned on, are you seeing any warnings like...

print() on closed filehandle OUT at line 23.

I'm just making up 'line 23'... could be anything. The point is, I think you may be attempting to print to closed filehandles.

It's also possible that you're never satisfying the conditions of the if() block that actually prints to the files. Why not put in a little check with a print statement that prints "Printing to files...\n". That way at least you'll know whether or not you're entering the if block that does all the output.


Dave

Replies are listed 'Best First'.
Re^2: printing to filehandles
by technofrog (Initiate) on Sep 02, 2005 at 08:00 UTC
    Thanks for your quick reply! I went back through the code and attempted to redo the indentions - hope that hepled. I added the "die's" to the end of the print commands, but nothing died...it seems to think that it's actually printing. (No warnings either.) Also, I have some prints to STDOUT during the print chunk of the code that happens when the if() block is executed that happen just fine. Could this have something to do with factors other than the code itself such as file permissions or something? I'm running Mac OSX (Darwin). I learned perl/UNIX on a pre-configured HPUX workstation at work this summer, and I have not done any configuration to this machine except add an alias to my .bashrc file and load some perl modules. Thanks again! David
      It's quite possible that this is related to something outside of perl, hence the suggestion to check the $! error string:
      open(FH, '>', $outfile) or die "can't open $outfile: $!";
      This should tell you more about what's going on.
        Also, I'm getting:
        syntax error at forex.pl line 37, near ")}" Unmatched right curly bracket at forex.pl line 62, at end of line syntax error at forex.pl line 62, near "}" Execution of forex.pl aborted due to compilation errors.
        with your code.