PERL_VERSION get the Perl version used by MATLAB

cached for speed

Contents

Output

function v = perl_version()

persistent perlv perlv_cached

if isempty(perlv_cached)
  perlv_cached = false;
elseif perlv_cached
  v = perlv;
  return
end

cmd = sprintf('"%s" -e "print $^V"', stdlib.perl_exe());

[s, r] = system(cmd);

if s == 0
  v = sscanf(r, 'v%d.%d.%d').';
else
  v = [];
end

% cache the result - even if empty -- because the check takes up to 1000 ms say on HPC
perlv = v;
perlv_cached = true;

end