SPUG: how to add text at start of a already existing file

Adam Monsen haircut at gmail.com
Tue Jan 18 08:44:35 PST 2005

On Tue, 18 Jan 2005 17:08:35 +0550, Sachin Chaturvedi
<sachin_chat at coolgoose.com> wrote:
> hi i want to add text at very start of already existing file.
> i have tried this code but it is adding only at end

use IO::All;
my $contents < io('file.txt');
"At start\n" . $contents > io('file.txt');

IO::All could potentially optimize this "prepending". Hmm, a
->prepend() method might be a welcome addition to IO::All.

Adam Monsen <adamm at wazamatta.com>

More information about the spug-list mailing list