in reply to writing to a file
If you need to add more than one line, you can get your new content into an array and loop through it:use Tie::File; my $file = 'filename'; my @tiedfile; my $new_content = "foo"; ## Whatever you want to prepend to the file tie(@tiedfile, 'Tie::File', $file); unshift(@tiedfile, $new_content); untie(@tiedfile);
foreach my $line (reverse(@new_content)) { unshift(@tiedfile, $line); }
|
|---|