I know hardly anything about perl syntax, but after a quick google search and a couple of minutes on this site
, I got this to work:
perl -i -ple 's/error/debug/g if $. == 100; close ARGV if eof' file
Apparently the last part is only necessary if you're processing multiple files, as you need to reset the $. count for each new file.
There are also examples there on using ranges and how to exclude lines. Check it out.