Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IPC using Perl

Status
Not open for further replies.

SaltyDuke

Programmer
Sep 18, 2002
140
IE
Hello!!

i have a bit of a strange noodle-scratcher at the moment.

i have a program that "writes" data out to another program which in turn parses that data and writes it to a database.

i would like to write a Perl program to do this. Is this a good idea or should i go for C instead? (i'm very lazy though!!)

if it is possible for Perl to "listen in" for info off another process (via stdin or stderr i guess), how do i do it? it can't just be:

$var = <STDIN>;

can it???

Thanx in advance for any help,
TheSaltyDuke [pipe]
 
It sounds like you just want a pipe. The easiest way is to pipe the output of the program to your Perl script from the command line when you call it:

%perl script | prog

An alternative if the parsing program is known is to open a file handle inside your script:
Code:
#!usr/bin/perl -w

open(PARSER, &quot;parser |&quot;) or die $!;

while (<PARSER>)
{
    print $_, &quot;\n&quot;; # Just print it to test
}

close(PARSER);
 
Thanx a million Akarui, you're a star!!!

:-D


TheSaltyDuke [pipe]
 
wait a minute... will this work on Windows or is it UNIX only code???

thanx again...sorry to double post!! :)

TheSaltyDuke [pipe]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top