in reply to Interacting with other programs

If I understand your question well, then you're normally executing a matlab file by typing ./myscript.m. That will launch matlab and feed it with the script, if there's something like #!/usr/bin/matlab. Or you are used to double-click such files in a GUI-enabled file manager and the operating system has the files associated with the appropriate interpreter (like matlab in your case) and runs it for you.

You simply need to explicitly say that you want to run matlab and pass it your script as an argument. That is, instead of saying "myscript.m", say "matlab myscript.m", since that's what happening behind the scenes anyway.

A note: I have never even seen Matlab, so the things about launching Matlab scripts and the #!/usr/bin/matlab line are pure assumptions.

Update: It just occured to me that you might be "running the input file" in interactive mode. If you run Matlab, it gives you a command line and from there you type a command to process a file, and you want to do this from perl, then things will be a bit more complicated, I fear.

I'd suggest trying to find a way to tell Matlab to process the file from command line (there should be an option or maybe the syntax I used in the above example could work). If that can't be done, then I guess you'll have to feed the command to the interpreter via STDIN. That would mean, if you normally write:

OS prompt $ matlab ... Matlab welcome message ... Matlab prompt $ run my_script.m

then you'd say in perl: system ('echo "run my_script.m" | matlab')