You would normally run such a script as follows: let's say you saved the script as /home/yourname/bin/add-exits-to-php.pl and let's also assume that the directory /home/yourname/bin is already mentioned in your shell's PATH variable.
Given those assumptions, you can go to the directory where the php files are stored, and edit them all with these two command lines:
cd /path/to/php_files/
add-exits-to-php.pl *.php
In the (unlikely) event that there are so many php files (and their names are so long) that the shell can't fit them all on one command line (you see a report like "command line too long"), you could use the following approach instead:
cd /path/to/php_files/
ls | grep '\.php$' | xargs add-exits-to-php.pl
The "xargs" command is a standard *n*x utility that will accept an input list of any length, and will run a command as many times as necessary to make sure that the full list is processed using the given command. |