Are you sure you're running this script with the Perl interpreter? The "command not found" is something a command script interpreter (like CMD.EXE or bash) might say.
Rather than just giving us one line, and asking us to guess, show more code. It's odd that you get to line 18, but maybe you start with a lot of comments.