Main Content


Call Perl script using operating system executable



perl(perlfile) calls the Perl script perlfile.

On Microsoft® Windows® systems, MATLAB® ships with Perl, which is available from the website. For information about using the Perl programming language, Perl source code, and a standard distribution of Perl, see

On Linux® and Mac systems, MATLAB calls the Perl interpreter available with the operating system.

perl(perlfile,arg1,...,argN) calls the script with the arguments arg1,...,argN.

result = perl(___) returns the results. Use this option with any of the input arguments from the previous syntaxes.

[result, status] = perl(___) returns the exit status in status.


collapse all

Create a file containing these statements:

$input = $ARGV[0]; 
print "Hello $input.";

Save the file on your MATLAB path.

At the MATLAB command line, type:

ans =
Hello World.

Input Arguments

collapse all

Perl script file name, specified as a string or character vector.

Example: ''

Perl script input arguments 1 through N (if any) required by perlfile, specified as strings or character vectors. The script specifies the arguments.

Output Arguments

collapse all

Script output, returned as a string.

Script exit status, returned as an integer.


  • Consider using Perl scripts instead of MATLAB code when:

    • You want to use an existing Perl script.

    • You want to preprocess data quickly. MATLAB reads Perl script formatting more easily than other formatting.

    • Perl has features not supported by MATLAB.

Version History

Introduced before R2006a

expand all

Behavior changed in R2021b

Behavior changed in R2021a

Behavior changed in R2019b

Behavior changed in R2018a

Behavior changed in R2017b