On Mar 19, 8:31 pm, [email protected] (Walt Chen) wrote:
> Hi
>
> I have a public disk partition shared by different users. Everyone on
> the host writes different temporary file from time to time. So the
> partition runs out of available disk space sometimes.
>
> I have a perl script to write some data to a file in this partition
> everyday. In several cases, the data is incomplete due to disk-full
> issue and i want to detect this error.
>
> I use 'print HANDLE $data' to write the data. CPAN says if the
> function 'print' runs successfully, the return value is true. However,
> it seems that no matter the data is fully written to the file, 'print'
> always returns true. Now I have resolved the problem by replacing
> function 'print' with 'syswrite'. But I wonder is function 'print'
> really so unfriendly to raise IO error?
See: perldoc -q buffer
This will explain why 'syswrite' will report error, say a
full disk partition, when print may not due to buffering.
And the remedy from the above docs is to force
unbuffering :
$old_fh = select(OUTPUT_HANDLE);
$| = 1;
select($old_fh);
--
Charles DeRykus
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/