If it's only for the first line, use this instead:
use strict; use warnings; use Tie::File; tie my @xfil, 'Tie::File', 'var.txt' or die $!; $xfil[0] =~ s/the line to be replaced/this is the new line/; untie @xfil;
Substantially less cumber. :-)
-- Ken
In reply to Re^5: A Better Way
by kcott
in thread A Better Way
by toniax
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |