Perl Topics





Español Français 中文 Deutsch Portuguese Japanese nederlands
   
 
Perl Tutorial
Introduction Introduction
Installing Perl Installing Perl
Basics of Perl Basics of Perl
Scalar Variables Scalar Variables
Operators Operators
Control Structures Control Structures
Lists Lists
Array Array
Arrays Manipulation Arrays Manipulation
Arrays Functons Array Functions
Hash Hash
Hash Functions Hash Functions
String Functions String Functions
Regular Expression Regular Expression
Regular Expression Functions Regular Expression Functions
Numerical Functions Numerical Functions
List Functions List Functions
User Defined Function User Defined Function
File Handling File Handling
Forums Ask Your Doubts
Feedback Feedback
 





qx/STRING/ Function of Regular Expression in Perl


Tutorials Perl

Topic

What is qx/STRING/ Function of regular expression in Perl?
How to execute system commands?


Explanation

The qx/STRING/ function will execute system commands and can be an alternate to back-quotes.

Syntax:
     qx/STRING/;

In the above syntax any delimiters can be used like (,^ or anything instead of "/".

Example to execute system commands:
    #! C:\programfiles\perl\bin\perl
    print "content-type: text/html\n\n";
    $sys  = qx(dir c:\\);      
    print "The drive c: details are:$sys";
Result:
    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.

Note:

Usually the drive details will be printed in same line, we have split it in different lines for the ease of display.






A Note
Simple introduction, basic CGI perl programming codes with examples. Do send your feedback or suggestions on this tutorial. This is a copyright content.

Other Links

web hosting