PERL q(),qq(),qx() Function:
qq():
Syntax:
Definition and Usage:
qq() can be used instead of double quotes. This is not really a function, more like an operator, but you'll probably look here if you see it in another programmer's program without remembering what it is. You can actually use any set of delimiters, not just the parentheses.
Return Value:
Example:
Try out following example:
$var = 10;
print(qq(This is a single quoted string with interpolation, $var));
|
It will produce following results:
This is a single quoted string with interpolation, 10
|
q():
Syntax:
Definition and Usage:
q() can be used instead of single quotes. This is not really a function, more like an operator, but you'll probably look here if you see it in another programmer's program without remembering what it is. You can actually use any set of delimiters, not just the parentheses.
Return Value:
Example:
Try out following example:
$var = 10;
print(q(This is a single quoted string without interpolation, $var));
|
It will produce following results:
This is a single quoted string without interpolation ,$var
qx():
Syntax:
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:
# summarize disk usage for the /tmp directory
# and store the output of the command into the
# @output array.
@output = qx(dir);
print "@output\n";
|
It will produce following results:
Volume Serial Number is E8C9-0715
Directory of C:\Documents and Settings\MOB100001692\My Documents\Downloads
01/04/2011 03:04 PM <DIR> .
01/04/2011 03:04 PM <DIR> ..
01/04/2011 01:11 PM 0 Firefox Setup 3.6.13.exe
01/04/2011 01:11 PM 1,368,877 Firefox Setup 3.6.13.exe.part
01/04/2011 03:06 PM 0 installed_versions'
...
No comments:
Post a Comment