in reply to add a line in file at start of file
Tie::File is handy for that kind of thing.
use Tie::File; for (glob '*.{c,h}') { tie my @file, 'Tie::File', $_ or warn $! and next; unshift @file, '#include something3.cfg'; }
The problen with seek and friends is that you wind up overwriting the original first line, as you say.
Without Tie::File, the way to do this is to write the new first line to a temp file, then copy the rest of the original to temp and rename temp to original.
After Compline,
Zaxo
|
|---|