You don't want to append, you want to prepend. The only possible way it to create a new file, write the new content, then copy the rest of the old file, and rename the new file to the old file's name.
my $new_filename = 'newfile.txt';
my $old_filename = 'oldfile.txt';
open my $new, '>', $new_filename or die "$new_filename: $!";
open my $old, '<', $old_filename or die "$old_filename: $!";
print {$new} "Prepending at the beginning of the file.\n";
print {$new} $_ while <$old>;
close $new;
rename $new_filename, $old_filename or die "rename: $!";