After looking at the code i can say it would only create new Matlab process if the earlier $ml getting "undef" in return. Also assuming a neat code (use my with new variable $ml use strict and warnings and also use win32::OLEs warning option to get more info on it etc)is causing the same --then the question comes to me how are you running the perl code. Unless you are running perl code from within Matlab how would perl be even aware of the existence of existing Matlab OLEs(correct me if i am wrong but its my understanding of OLEs). Unless you run Matlab from within perl like below,
#!/usr/bin/perl
#
use strict;
use warnings;
use Win32::OLE;
use Win32::OLE::Variant;
Win32::OLE->Option(Warn => 3);
my $Count = Win32::OLE->EnumAllObjects(sub {
my $Object = shift;
my $Class = Win32::OLE->QueryObjectType($Object);
printf "# Object=%s Class=%s\n", $Object, $Class;
});
print "Found $Count OLE Object(s)\n";
If this generates any output then you can consider the approach you are trying. It would be easy by not bothering with OLE, import, say, a CSV file with Matlab import. I would probably start along that
route: write a CSV file with the data you want in Perl, and then import
it into matlab from the matlab macro.