in reply to Re: Elegant Way of Inserting Text at the Start of the File
in thread Elegant Way of Inserting Text at the Start of the File
So, this will print the Hello as the first line, but it means that I have to open the file, output the result to a new file, delete the old file, and rename the new file as the old file.#!/usr/bin/perl while (<>) { BEGIN { print "Hello\n"; } print $_; } Then print Hello as the first line of text in a file.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Elegant Way of Inserting Text at the Start of the File
by graff (Chancellor) on Nov 19, 2008 at 05:34 UTC | |
|
Re^3: Elegant Way of Inserting Text at the Start of the File
by ikegami (Patriarch) on Nov 19, 2008 at 06:10 UTC | |
|
Re^3: Elegant Way of Inserting Text at the Start of the File
by harishnuti (Beadle) on Nov 19, 2008 at 07:36 UTC |