in reply to Append to beginning of line (multi line file)
or in your could you could change:perl -pi.bak -e '$count++;s/^/$count. /' file_name
to something like:foreach my $line (@file) { (undef) = <FILE>; # stores number of lines into $. $count++; print FILE, "$count. "; if ($count == $.) {last; } }
or:foreach my $line (@file) { $count++; print FILE, "$count. $line"; }
As always TMTOWTDI. I am curious as to why this line:foreach (@file) { $count++; s/^/$count. /; print FILE; }
and this line:(undef) = <FILE>; # stores number of lines into $.
is necessary.if ($count == $.) {last; }
-enlil
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Append to beginning of line (multi line file)
by theorbtwo (Prior) on Jan 23, 2003 at 20:43 UTC |