Categories:
.NET (961)
C (387)
C++ (185)
CSS (84)
DBA (8)
General (31)
HTML (48)
Java (641)
JavaScript (220)
JSP (109)
JUnit (31)
MySQL (297)
Networking (10)
Oracle (562)
Perl (48)
Perl (9)
PHP (259)
PL/SQL (140)
RSS (51)
Software QA (28)
SQL Server (5)
Struts (20)
Unix (2)
Windows (3)
XHTML (199)
XML (59)
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, 1696👍, 0💬
Popular Posts:
How To Retrieve the Count of Updated Rows? - Oracle DBA FAQ - Working with Database Objects in PL/SQ...
How can we implement singleton pattern in .NET? Singleton pattern mainly focuses on having one and o...
What are the different accessibility levels defined in .NET ? Following are the five levels of acces...
What is Traceability Matrix? Traceability Matrix is one of the document will prepare by QA.To make s...
What is thread? A thread is an independent path of execution in a system.