do you have to have the whole file in $ctfilebuf? It will be a lot easier if you simply read/scan it line by line .. you can keep a counter of the line numbers (or use the
$. variable -- see
perlvar)
Also,
grep -n Cell log.txt from the commandline accomplishes this as well