Perl Programming/Keywords/qx
Appearance
The qx keyword
[edit | edit source]qx is a command that contains a string that may be interpolated. It is then executed as a system command with /bin/sh or similar. Wildcards, pipes, and redirections of the shell are taken into account. The collected standard output of the command is returned, and standard error remains unchanged. In scalar context, it comes back as a single string that may be multi-lined, or an undef, if the command failes. In list context, it returns a list of lines (however you've defined lines with $/ or $INPUT_RECORD_SEPARATOR), or an empty list, if the command failes.
Syntax
[edit | edit source] qx/STRING/