Re: FAQ 5.2 How do I change, delete, or insert a line in a file, or append to the beginning of a file?



In article <ngkd64-fr8.ln1@xxxxxxxxxxxxxxxxxxx>, PerlFAQ Server
<brian@xxxxxxxxxxxxxx> wrote:


5.2: How do I change, delete, or insert a line in a file, or append to the
beginning of a file?


To change only a particular line, the input line number, $., is useful.
Use "next" to skip all lines up to line 5, make a change and print the
result, then stop further processing with "last".

while( <$in> )
{
next unless $. == 5;
s/\b(perl)\b/Perl/g;
print $out $_;
last;
}

This example results in a single line being written to the output file.
Is that is what is intended by "To change only a particular line"?

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
.