in reply to Do I need local $

You don't need to local $| at all. After you open your filehandle, if you want to turn on autoflush for that filehandle, you need to do something like this:

my $oldhandle = select(FILEHANDLE); $|=1; select( $oldhandle );

Another option (probably better) is to look at FileHandle, which includes an autoflush() method.