How To Avoid a Perl script calling an Another Perl Script

Posted by rockyurock on Stack Overflow See other posts from Stack Overflow or by rockyurock
Published on 2010-04-04T09:26:59Z Indexed on 2010/04/04 9:33 UTC
Read the original article Hit count: 857

Filed under:

Hello,

i am calling a perl script client.pl from a main script to capture the output of client.pl in @output.

is there anyway to avoid the use of these two files so i can use the output of client.pl in main.pl itself

here is my code....


main.pl
=======

my @output = readpipe("client.pl");


client.pl
=========

#! /usr/bin/perl -w
#use strict;
use Socket;

#initialize host and port


my $host = shift || $FTP_SERVER;


my $port = shift || $CLIENT_PORT;

my $proto = getprotobyname('tcp');

#get the port address
my $iaddr = inet_aton($host);
my $paddr = sockaddr_in($port, $iaddr);

#create the socket, connect to the port
socket(SOCKET, PF_INET, SOCK_STREAM, $proto)or die "socket: $!\n";
connect(SOCKET, $paddr) or die "connect: $!\n";

my $line;
while ($line = )
{
print "$line\n";
}
close SOCKET or die "close: $!";

/rocky..

© Stack Overflow or respective owner

Related posts about perl