< Perl Programming < Keywords

The qx keyword

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

  qx/STRING/
This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.