Paul - The Programmer

simple & stupid

how to use the non-buffered stdout of Perl

At first, it's really a interesting bug.  I can't help writing it down.

I write a perl script which should be running quietly and infinitely on the background. I don't like to do writing the run-time log into a file directly in the script. So, I decide to just redirect the stdout to a file when I execute the script.

Now, here comes the werid bug. I start up the script. It works well. Everything is well except there is no log in the redirected stdout file. But after I disable the infinite loop, let it just run one time and exit.  Suprisedly,  the run-time logs appear in the redirected stdout file.

Fortunately, I realize that the problem of perl's output functionality at last.  With default behavior, Perl saves the output strings in a buffer instead of do phsical write to screen everytime. If I kill the script when it's running, then Perl doesn't have the opportunity to write the buffered strings to the screen. The solution is simply adding the code '$| = 1;'  to the begining of the script . It tells Perl using non-buffered I/O to the screen.

Furthermore,  in the case of using the non-buffered I/O to other device.  We can refer to the example below.

$oldh= select(DEV);

$| =1;


Nice weekend. 

I am also annoyed

Spend more than 4 hours on the road every day.  Why it's so difficult to change to a nearer hotel?  Why there are always endless big fairs . That's the reason I hate big city so much. I'm also realy annoyed to the assistants who has transfered to another part of company and refuse to support me.

what's a mess.   : (

how to survive in Dusseldorf

every cent  i spend should multiply  at least 11 for changing to Chinese money. It's very hurt when pay for things by cash.

and also the cold of April is underestimated.

everything is quite different.

let's see...

how to across more than a quarter of earth in one day

Receive an invitation from a company in the city Dusseldorf, Germany.

Request the approval from the big boss and ask him/her kindly offer you a guarantee letter.

Ask a travel agency to order the airplane tick and book hotel for you.

Apply an international credit card and change enough cash.

Apply visa from the embassy of Germany. Actually, it looks much more like you fight with the bastards untill them give you the permission to enter the country.

Hope nothing has been left behind. And waiting for taking off.

To be continued ...