Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello monks,

I've been using the following code thanks to jmcnamara

if ($^O eq 'MSWin32') { open my $fh, "+<$Conf[1]" or warn "$!"; binmode $fh; my $size = 4096; seek $fh, -$size, 2; # Locate the end of the file while (1) { $cur_pos = tell $fh; read $fh, $buf, $size; last if $buf =~ m/\S/s; seek $fh, -$size*2, 1; } $buf =~ m/(\s*)$/s; $cur_pos += $-[0] || 0; truncate $fh, ++$cur_pos if $cur_pos; close $fh; }
I had to check for the OS because this routine fails on Unix, does anyone know why?