Copyright © tutorialspoint.com

PERL qx(EXPR) Function


Syntax

qx EXPR


Definition and Usage

qx() is a alternative to using back-quotes to execute system commands. For example, qx(ls -l) will execute the UNIX ls command using the -l command-line option. You can actually use any set of delimiters, not just the parentheses.

Return Value

  • The return value from the executed system command.

Example

Try out following example:

#!/usr/bin/perl -w

# summarize disk usage for the /tmp directory
# and store the output of the command into the
# @output array.
@output = qx(du -s /tmp);

print "@output\n";

It will produce following results:

176     /tmp

Copyright © tutorialspoint.com