Anything you need to do with grep or sed can be done natively in perl more easily. For instance (this is roughly right, but probably wrong):
my @linenumbers;
open FH "<$fileToProcess";
while ()
{
next if (!m/textToFind/);
chomp;
s/^\([0-9]*\)[:].*/\1/;
push @lineNumbers, $_;
}