I believe it is to be expected, because normally you pipe to a command or to an executable. After all, piping is essentially redirecting output going to a filehandle to some executable's STDIN. See perlopentut for more details
In this case, it's expecting 'foo.plx' to be an executable Perl script. Was the original file (sort3.plx) an existing Perl script?
If so, I suppose the workaround would be to check whether the command or script you want to pipe to actually exists first. Also, you want to get into the habit of using the
three-argument version of open, considering that the two-argument version (used most often in educational texts) has some potential security issues when used with a variable filename.