LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   perl script output cannot pipe to file (https://www.linuxquestions.org/questions/programming-9/perl-script-output-cannot-pipe-to-file-850073/)

hattori.hanzo 12-14-2010 12:28 AM

perl script output cannot pipe to file
 
I have a strange problem. My perl script produces the output when I run from the command line but when I pipe it to a file, it just hangs. ie. no output to the file at all.

Additional info:
There is one subroutine which does an ldap lookup, then passes the result via a 'return', then I 'print' the variable. This is all done in a while loop processing a list from a file.

Any pointers?

Thanks & Regards,

druuna 12-14-2010 01:51 AM

Hi,

Without the actual code it is a bit hard to guess what could be wrong.

One thing that does come to mind: Could it be that you are encountering perl's buffered output? Have a look here: Suffering from Buffering?

Hope this helps.

hattori.hanzo 12-14-2010 06:46 PM

Thanks Druuna,

Thats a real interesting article about buffering in perl.

I ended up using the
Code:

$|++;
statement right after I open the file. I thought it was was the easiest to implement after also reading this.

Thanks & Regards

druuna 12-15-2010 02:26 AM

You're welcome :)


All times are GMT -5. The time now is 05:53 AM.