There is not a single command to insert a line into a file. The Tie::File module gives a convenient way to do it.
If you wish to insert a line elsewhere, splice works with that.use Tie::File; my $newline = "whatever"; { tie my @array, 'Tie::File', '/path/to/file.txt'; unshift @array, $newline; }
After Compline,
Zaxo
In reply to Re: need help:insert a line in a textfile
by Zaxo
in thread need help:insert a line in a textfile
by star7
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |