Even if you say that portability is not a problem, you never know for sure what the future holds, so I would advise you to reconsider this position. For example, one day I was asked to migrate an editor that was written (by someone else) from Unix to DOS. Initially, the program was not supposed to be ported and was written using special Unix calls deeply embedded in the code. After considering the amount of work required, we abandoned this task for too much time.
I used exec calls in PHP; however, I had no other way to achieve what I needed (I had to call another program written in another language, without another bridge between the languages). However, IMO, exec calls that are not needed are ugly. As others have said, they can also create security risks and slow down your program.
As you said yourself, you need to document exec calls to make sure they are understood by programmers. Why create extra work? Not only now, but also in the future, when any changes to the exec call should also be documented.
Finally, I suggest you learn a little PHP and its functions. I'm not so good with PHP, but in just a few minutes with Google and php.net , I think I did the same thing you gave as an example:
$search_results = preg_grep($search_string, file($file_name)); foreach ($search_results as $result) { echo $result . "\n"; }
Yes, this is a bit more code, but not so much, and you can put it in a function if necessary ... and I won’t be surprised if the PHP guru could shorten it.
Greenmatt
source share