use strict; use warnings; use Tie::File; my $string = "Text to be prepended.\n"; my @array; { my $obj = tie @array, 'Tie::File', "guestbook.txt" or die "Can't open the guestbook file. $!\n"; $obj->flock; unshift @array, $string; untie @array; }