Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
How to read from a pipeline with Perl
How to read from a pipeline with Perl
✍: Guest
Example 1:
To run the date command from a Perl program, and read the output
of the command, all you need are a few lines of code like this:
open(DATE, "date|");
$theDate = <DATE>;
close(DATE);
The open() function runs the external date command, then opens
a file handle DATE to the output of the date command.
Next, the output of the date command is read into
the variable $theDate through the file handle DATE.
Example 2:
The following code runs the "ps -f" command, and reads the output:
open(PS_F, "ps -f|");
while (<PS_F>) {
($uid,$pid,$ppid,$restOfLine) = split;
# do whatever I want with the variables here ...
}
close(PS_F);
2013-09-05, 2167👍, 0💬
Popular Posts:
What are the high-level thread states? The high-level thread states are ready, running, waiting, and...
What will be printed as the resultof the operation below: int x; int modifyvalue() { return(x+=10); ...
How To Use an Array as a Queue? - PHP Script Tips - PHP Built-in Functions for Arrays A queue is a s...
Can one execute dynamic SQL from Forms? Yes, use the FORMS_DDL built-in or call the DBMS_SQL databas...
What will be printed as the result of the operation below: main() { char s1[]="Cisco"; char s2[]="sy...