http://www.perlmonks.org?node_id=354836


in reply to writing to the top of a file

Due to the nature of the structure of files you can't write to the top of them. So a simple solution is to create a new file and overwrite the old file e.g
open( my $old, '<', 'current.log' ) or die "ack: $!"; open( my $new, '>', 'current.log.new' ) or die "ack: $!"; print {$newfh} $your_data_here; print {$newfh} $_ while <$old>; close $old; close $new; rename 'current.log.new', 'current.log';
HTH

_________
broquaint