주요 콘텐츠

perl

R2026b

Call Perl script using operating system executable

Description

result = perl(perlfile) calls the Perl script perlfile and returns the script output.

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

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

example

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

[result,status] = perl(___) returns the exit status in status. You can specify two output arguments with any of the input argument combinations in the previous syntaxes.

Examples

collapse all

Create a file named hello.pl that contains these Perl statements:

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

Save the file on your MATLAB path.

From the MATLAB command line, run the Perl script with the input "World".

result = perl("hello.pl","World")
result =
'Hello World.'

Input Arguments

collapse all

Perl script filename, specified as a string scalar or character vector.

Example: "myscript.pl"

Perl script input arguments 1 through N (if any) required by perlfile, specified as string scalars or character vectors. The Perl script uses these specified arguments.

Output Arguments

collapse all

Script output, returned as a character vector. If the Perl script runs successfully, the status value is 0.

Script exit status, returned as an integer.

Tips

  • 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