qx/STRING/ Function of Regular Expression in Perl
What is qx/STRING/ Function of regular expression in Perl?
How to execute system commands?
The qx/STRING/ function will execute system commands and can be an alternate to back-quotes.
In the above syntax any delimiters can be used like (,^ or anything instead of "/".
Example to execute system commands:
print "content-type: text/htmlnn";
$sys = qx(dir c:\);
print "The drive c: details are:$sys";
The drive c: details are:
Volume in drive C has no label.
Volume Serial Number is 1C99-C1C2
Directory of c: 06/30/2009 08:17 AM 33,
148 aaw7boot.log 01/21/2009 07:45 PM 0
AUTOEXEC.BAT 01/21/2009 07:45 PM 0
CONFIG.SYS 3 File(s) 33,
148 bytes 0 Dir(s)
10,424,741,888 bytes free
In the above code we have executed system commands and got the details about the drive "c:\", using the "qx" function, it displays all the details about that drive.
Usually the drive details will be printed in same line, we have split it in different lines for the ease of display.