in reply to current array index
$_[$_] =~ s/dienice\(\"/dienice\(\"Line $counter/ for (0 .. scalar @_);
That's untested and frankly I'm a little disgusted with it myself.