One could write here an *.m file for Matlab without using Matlab text editor or just comment the following lines till line EOF
.
Start to write into 'Call_mfile.m' all lines after print $matlab <<EOF;
open(my $matlab, '>', 'Call_mfile.m');
print $matlab <<EOF;
close all;
clear all;
clc;
% write here your Matlab code
a = zeros(10)
%--------------------------------------------------------------------------
EOF
###########################################################################
# Use this command when you want to update your toolbox
#system('matlab rehash toolboxcache')
# Use this when you want to use Java interface!
# Notice!!
# This could not then open another files which are called in Call_mfile.m
# file. Otherwise use the next command!
#system('matlab -nojvm -r Call_mfile');
system('matlab -r Call_mfile');