[18673] in Perl-Users-Digest
Perl-Users Digest, Issue: 841 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun May 6 03:05:39 2001
Date: Sun, 6 May 2001 00:05:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <989132707-v10-i841@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sun, 6 May 2001 Volume: 10 Number: 841
Today's topics:
Advanced Object Oriented Perl Class <uri@sysarch.com>
Re: DOS Perl convering LF to CR/LF <admin@ase-ga.com>
Re: Help on optimization wanted <andras@mortgagestats.com>
Re: Help slim down Perl code (Logan Shaw)
Re: Help slim down Perl code (Falc2199)
Re: Help slim down Perl code <carvdawg@patriot.net>
Re: Help slim down Perl code (Logan Shaw)
Re: Help slim down Perl code <uri@sysarch.com>
How to determine file type of a filehandle? <djmarcus@ex-pressnet.com>
Re: How to execute a perl script from a perl script? - <godzilla@stomp.stomp.tokyo>
Re: How to execute a perl script from a perl script? - <bop@mypad.com>
Re: leftover Close Wait sockets <skilchen@swissonline.ch>
Re: NT version of LWP::UserAgent <hmoylanremovethis@swbell.net>
Re: Passing references via recursion <joe+usenet@sunstarsys.com>
Re: Passing references via recursion <skilchen@swissonline.ch>
Re: removing the \n from the data obtained from a text <krahnj@acm.org>
Re: System call within Daemon <goldbb2@earthlink.net>
The Canonical Program (was Re: I remember someone made (Tramm Hudson)
Re: The Canonical Program (was Re: I remember someone m <bop@mypad.com>
Re: Using Modem::Vgetty <JIMIT@prodigy.net>
What is the best module... <bop@mypad.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 06 May 2001 05:28:50 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Advanced Object Oriented Perl Class
Message-Id: <x7r8y3cag0.fsf@home.sysarch.com>
Advanced Object Oriented Perl Class
in Boston, July 10-11
Damian Conway will be teaching his advanced object oriented class in
Boston on Tuesday/Wednesday, July 10-11, 2001. The class will be at the
Cambridge Marriott which is located in East Cambridge, on the
Kendall/MIT stop of the Red Line subway. It is only 5 miles from Logan
airport, close to downtown Boston and Harvard Sq. and is easily reached
by car or public transportation.
Damian is the author of Object Oriented Perl, numerous Perl modules, has
given lectures at major Perl and Open Source conferences and is a
recognized expert in Object Oriented programming.
Damian has taught his Advanced OO Perl course all over the world to
great acclaim. He is justly famous for his lecturing style which
combines education and entertainment in a way that keeps his audience in
rapt attention. His classes are not just a typical learning experience
from a book or notes. Here is a rare opportunity for you to learn about
OO Perl directly from the master. This will be a small class of no more
than 30 students so you be able to have quality interactions with Damian
and have your questions answered. Damian won't be back in Boston for at
least a year so don't lose out on a great opportunity.
How to register and much more information can be found at:
http://www.sysarch.com/perl/OOP_class.html
There are already 10 registrants so register early to guarantee your
seats.
If you have any questions or feedback, send email to uri@sysarch.com.
Thanx,
Uri Guttman
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info: http://www.sysarch.com/perl/OOP_class.html
------------------------------
Date: Sun, 06 May 2001 01:35:16 GMT
From: "GArlington" <admin@ase-ga.com>
Subject: Re: DOS Perl convering LF to CR/LF
Message-Id: <oT1J6.7107$Cf.1144670@news1.cableinet.net>
"\n" will translate to LF or CR/LF depending on platform used.
To stop conversion read the file as binary.
G.A.
David <dbmartin5@home.com> wrote in message
news:md19ft8no5d7r69vhu8rqig9odu2fqjkps@4ax.com...
> I am reading a Unix file on a DOS machines which contains lines ending
> in a LF. The program reads in the line, but when I reprint them to
> another file, the LF is now a CR/LF! Is there a way to prevent perl
> from this conversion or do I need to cop off the end and print ending
> with a LF?
>
> Also, what is the control char(s) for LF only, eg. like the "\n" for
> CRLF?
>
> Thanks
>
------------------------------
Date: Sat, 05 May 2001 22:15:40 -0400
From: Andras Malatinszky <andras@mortgagestats.com>
Subject: Re: Help on optimization wanted
Message-Id: <3AF4B3CB.3BAD5C2B@mortgagestats.com>
Charlie Reiss wrote:
> In article <3af482be$1@e-post.inode.at>, Michael Ströck wrote:
> >Hi to all !
> >
> >One of our CS teachers at school told me to write a
> >script that finds all primes from 1 - n.
> >
> >Writing that script was easy, but as I'm very new to
> >Perl, I'd really appreciate any comments on how to
> >make the following script run faster.
> >
> >What I've done so far:
> >- I only divide by known primes.
>
> You don't need to check all known primes, even. See below.
>
>
> [snip]
>
> # if a number is factorable into x*y, then
> # either x and y must equal sqrt(the number)
> # or one must be greater, and one lesser.
> # Proof is simple.
Ah, the famous technique of Proof by Intimidation!
------------------------------
Date: 5 May 2001 20:27:40 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Help slim down Perl code
Message-Id: <9d29ac$fke$1@boomer.cs.utexas.edu>
In article <20010505191621.15352.00002168@ng-xc1.aol.com>,
Falc2199 <falc2199@aol.comNOJUNK> wrote:
>I have here a lot of reduntant code. I need a way to slim it down. It bascially
>does the same thing over and over, open and a file and read the contents into
>an array....
>
>$lChoiceFile = 'lChoice.txt';
>
>open (LCHOICE,"<$lChoiceFile");
>@lCarray=<LCHOICE>;
>close (lCHOICE);
>
>$oChoiceFile = 'oChoice.txt';
>
>open (OCHOICE,"<$oChoiceFile");
>@oCarray=<OCHOICE>;
>close (OCHOICE);
You can factor most of that out like this:
sub readFile
{
my ($filename) = @_;
my @lines;
if (not open (FOO, $filename))
{
warn "Can't open file \"$filename\" ($!)\n";
return undef;
}
@lines = <FOO>;
close FOO;
return \@lines;
}
$tmp = readFile ("foo.txt");
defined $tmp or handleErrors();
@blah = @$tmp;
Or, if you really want to read files in bulk:
@filesContents = map (readFile($_), @filenames);
if (grep (not defined $_, @filesContents))
{
die "Couldn't read one of the files.\n";
}
@file1 = @{shift @filesContents};
@file2 = @{shift @filesContents};
@file3 = @{shift @filesContents};
@file4 = @{shift @filesContents};
That's kind of ugly, though.
- Logan
--
my your his her our their _its_
I'm you're he's she's we're they're _it's_
------------------------------
Date: 06 May 2001 02:10:44 GMT
From: falc2199@aol.comNOJUNK (Falc2199)
Subject: Re: Help slim down Perl code
Message-Id: <20010505221044.05544.00002138@ng-ct1.aol.com>
Thanks for you help Logan, but there is still one thing I am not clear on.
>$tmp = readFile ("foo.txt");
> defined $tmp or handleErrors();
> @blah = @$tmp;
Will the value of the array which reads all the contents of "foo.txt" be in
@blah?
Thanks,
Jehan
Here is the entirety of the code..>sub readFile
> {
> my ($filename) = @_;
> my @lines;
>
> if (not open (FOO, $filename))
> {
> warn "Can't open file \"$filename\" ($!)\n";
> return undef;
> }
>
> @lines = <FOO>;
>
> close FOO;
>
> return \@lines;
> }
>
> $tmp = readFile ("foo.txt");
> defined $tmp or handleErrors();
> @blah = @$tmp;
>
>Or, if you really want to read files in bulk:
>
> @filesContents = map (readFile($_), @filenames);
>
> if (grep (not defined $_, @filesContents))
> {
> die "Couldn't read one of the files.\n";
> }
>
> @file1 = @{shift @filesContents};
> @file2 = @{shift @filesContents};
> @file3 = @{shift @filesContents};
> @file4 = @{shift @filesContents};
>
>
>
>
>
>
To e-mail, remove NOJUNK
------------------------------
Date: Sat, 05 May 2001 22:28:18 -0400
From: H C <carvdawg@patriot.net>
Subject: Re: Help slim down Perl code
Message-Id: <3AF4B6C2.1C2B2EF@patriot.net>
Why not just create a subroutine?
sub readfile {
my $file = $_[0];
die "File could not be found.\n" unless (-e $file);
open(FH,$file) || die "Could not open $file: $!\n";
my @filearray = <FH>;
close(FH);
return @filearray;
}
Once that is in your script, call it:
my @oCarray = readfile('oChoice.txt');
Falc2199 wrote:
> I have here a lot of reduntant code. I need a way to slim it down. It bascially
> does the same thing over and over, open and a file and read the contents into
> an array....
>
> $lChoiceFile = 'lChoice.txt';
>
> open (LCHOICE,"<$lChoiceFile");
> @lCarray=<LCHOICE>;
> close (lCHOICE);
>
> $oChoiceFile = 'oChoice.txt';
>
> open (OCHOICE,"<$oChoiceFile");
> @oCarray=<OCHOICE>;
> close (OCHOICE);
>
> $bChoiceFile = 'bChoice.txt';
>
> open (BCHOICE,"<$bChoiceFile");
> @bCarray=<BCHOICE>;
> close (BCHOICE);
>
> It works fine but as you can see I am repeating it often. I think arrays/for
> loops or an openFile function might be a good way to cut it down but niether
> seem to work.
>
> You see I need each of those arrays @lCarry and @tCarry later on in the code.
> If I use arrays/ for loops then I need mulit-dimensional arrays and if I use a
> function then I think I have to pass these arrays by reference so the function
> can modify them. I an not sure Perl can do either of this.
>
> Do you any suggestions on how to make this code less repetitive?
>
> Thanks in advance for any help,
> Jehan
>
> To e-mail, remove NOJUNK
------------------------------
Date: 5 May 2001 22:08:09 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Help slim down Perl code
Message-Id: <9d2f6p$fuq$1@boomer.cs.utexas.edu>
In article <20010505221044.05544.00002138@ng-ct1.aol.com>,
Falc2199 <falc2199@aol.comNOJUNK> wrote:
>Thanks for you help Logan, but there is still one thing I am not clear on.
>
>>$tmp = readFile ("foo.txt");
>> defined $tmp or handleErrors();
>> @blah = @$tmp;
>
>Will the value of the array which reads all the contents of "foo.txt" be in
>@blah?
Yes. As I have written it, readFile() will create an array, fill that
array with the file's contents, and return a reference to that array
(or the value undef if there is an error). Then, the last line will
copy that array to the array @blah.
- Logan
--
my your his her our their _its_
I'm you're he's she's we're they're _it's_
------------------------------
Date: Sun, 06 May 2001 04:45:07 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Help slim down Perl code
Message-Id: <x7zocrccgj.fsf@home.sysarch.com>
>>>>> "HC" == H C <carvdawg@patriot.net> writes:
HC> Why not just create a subroutine?
HC> sub readfile {
HC> my $file = $_[0];
HC> die "File could not be found.\n" unless (-e $file);
HC> open(FH,$file) || die "Could not open $file: $!\n";
HC> my @filearray = <FH>;
HC> close(FH);
HC> return @filearray;
HC> }
might as well support wantarray and make it faster as well. this works
for both array and scalar context. use Carp or change the carp to a die.
sub read_file {
my( $file_name ) = shift ;
my( $buf ) ;
local( *FH ) ;
open( FH, $file_name ) || carp "can't open $file_name $!" ;
return <FH> if wantarray ;
read( FH, $buf, -s FH ) ;
return $buf ;
# older slow way
# local( $/ ) unless wantarray ;
# <FH>
}
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info: http://www.sysarch.com/perl/OOP_class.html
------------------------------
Date: Sat, 5 May 2001 21:45:27 -0400
From: "David J. Marcus" <djmarcus@ex-pressnet.com>
Subject: How to determine file type of a filehandle?
Message-Id: <tf9b541hkjlj31@corp.supernews.com>
Given a file handle, $fh, how can I determine what kind of file the handle
is associated with. In particular, the $fh can come from a socket, a disk
file, console, etc.
The environment is AS Perl 5.6.1, running on W'98 and W2K.
-TIA
David
------------------------------
Date: Sat, 05 May 2001 19:55:53 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: How to execute a perl script from a perl script? - nearly got it right !
Message-Id: <3AF4BD39.728AD5E5@stomp.stomp.tokyo>
HCCO admin wrote:
> Godzilla! wrote:
> >HCCO admin wrote:
> >> Godzilla! wrote:
> >> >HCCO admin wrote:
> >(snipped)
> >> So I refer you back to the original question.
> >In turn, I will refer you back to my advice and
> >politely suggest you read for comprehension.
> Yeah, erm, thanks, I've done that - what I want to do isn't possible
> with a SSI from the script in it's present location.
> So can anyone else help ?
"Experimentation will yield what methodology would
be best to use for your server as server brand and
server configuration are important externalities."
You are presenting yourself as the administrator
of this virtual server, m2n.co.uk and, as such,
you can configure your server to allow execution
of a program in any directory, directory tree or
across directories within the scope of your
server software.
Once again, I will suggest you read for comprehension.
Your subject line topic does not agree with your
body content dialog. Calling a script from within
another script is unrelated to server side includes.
Perhaps you are confused on what you need to do?
Godzilla!
------------------------------
Date: Sun, 06 May 2001 03:22:06 GMT
From: "flash" <bop@mypad.com>
Subject: Re: How to execute a perl script from a perl script? - nearly got it right !
Message-Id: <yr3J6.20473$_f3.429383@news20.bellglobal.com>
I finally got home and re-read your message.
you could do.
system(perl /path/to/script ubb=whos_online_ssi');
in the middle man cgi.
"BastionEX" <bastionex@hotmail.com> wrote in message
news:bX0J6.19211$nC6.2535529@news20.bellglobal.com...
> You can recompile apache to use the supercgi module.
>
> http://wss.hypermart.net/source/apache/mod_scgi.c.gz
>
>
> http://wss.hypermart.net/source/apache/
>
>
>
> I think that is what you want.
>
>
> "HCCO admin" <admin@nospam.m2n.co.uk> wrote in message
> news:shn8ft0cjf52tvrsg4vv576jbhfj0srjv8@4ax.com...
> > On Sat, 05 May 2001 11:59:57 -0700, "Godzilla!"
> > <godzilla@stomp.stomp.tokyo> wrote:
> >
> > >HCCO admin wrote:
> > >
> > >> Godzilla! wrote:
> > >> >HCCO admin wrote:
> > >
> > >(snipped)
> > >
> > >> So I refer you back to the original question.
> > >
> > >In turn, I will refer you back to my advice and
> > >politely suggest you read for comprehension.
> > >
> > >Godzilla!
> >
> > Yeah, erm, thanks, I've done that - what I want to do isn't possible
> > with a SSI from the script in it's present location.
> > So can anyone else help ?
>
>
------------------------------
Date: Sun, 6 May 2001 06:29:30 +0200
From: "Samuel Kilchenmann" <skilchen@swissonline.ch>
Subject: Re: leftover Close Wait sockets
Message-Id: <9d2kgj$fu3df$1@ID-13368.news.dfncis.de>
"Spork Boy" <sporkboy@Spork.na> wrote in:
news:slrn9f91mq.u4i.sporkboy@Spork.na...
> In article <9d19ct$g2uva$1@ID-13368.news.dfncis.de>, Samuel
Kilchenmann wrote:
> >
> > shutdown(SOCKET, 1) || die "shutdown write: $!";
> > while (<SOCKET> {
> > print;
> > }
> > shutdown(SOCKET, 0) || die "shutdown read: $!";
>
> It says there's an error near }
>
Sorry for the typo, the line
while (<SOCKET> {
should be
while (<SOCKET>) {
Ok, lets give it a last try. What happens if you run the following
script (with your WinampRC hostname and port as parameters) and enter
"quit" after the connection has been established? Is the final output
"remote closed connection"? If not, then WinampRC is buggy. If yes,
but the socket on the Winamp machine remains in CLOSE_WAIT state, then
either your Linux or Windows TCP/IP implementation or WinampRC has a
problem. But since you seem to get the same results from either Perl
or telnet, its most likely not a Perl problem.
----------%<-------------
#!/usr/bin/perl -w
use strict;
use IO::Socket;
use IO::Select;
unless (@ARGV == 2) { die "usage: $0 host port" }
my ($host, $port) = @ARGV;
my $socket = IO::Socket::INET->new(Proto => "tcp",
PeerAddr => $host,
PeerPort => $port)
or die "can't connect to port $port on $host: $!";
$socket->autoflush(1);
print STDERR "[Connected to $host:$port]\n";
my $sel = IO::Select->new(\*STDIN, $socket)
or die "error creating IO::Select instance for STDIN, socket";
LOOP: while (my @ready = $sel->can_read()) {
foreach my $fh (@ready) {
if ($fh == $socket) {
my $line = <$socket>;
unless (defined($line)) {
print STDOUT "remote closed connection\n";
$socket->shutdown(0) || die "shutdown socket read side: $!";
last LOOP;
}
else {
print STDOUT $line;
}
}
else {
my $line = <STDIN>;
if ($line =~ /quit/) {
$socket->shutdown(1) || die "shutdown socket write side: $!";
print STDOUT "asked remote to close connection\n";
}
else {
print $socket $line;
}
}
}
}
----------%<-------------
------------------------------
Date: Sun, 6 May 2001 00:57:10 -0500
From: "Bart" <hmoylanremovethis@swbell.net>
Subject: Re: NT version of LWP::UserAgent
Message-Id: <hK5J6.175$aI5.9170@nnrp1.sbc.net>
UserAgent for NT is readily available at www.activestate.com in the modules
section. i've put it on several nt boxes.
smilepak <smilepak@hotmail.com> wrote in message
news:xd1I6.3108$Cq3.285904@newsread1.prod.itd.earthlink.net...
> anyone know if there is a version of LWP::UserAgent for the NT version of
> Perl? If so, where and how can I obtain a copy of it?
>
> KN
>
>
>
------------------------------
Date: 05 May 2001 23:51:34 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Passing references via recursion
Message-Id: <m3bsp72kzd.fsf@mumonkan.sunstarsys.com>
"Arvin Portlock" <temp133@hotmail.com> writes:
> I'm using recursion on a tree to append data to a variable.
> I want to try and do it without using global variables. I can't
> seem to do it.
Did you enable warnings and strictures then?
> Here's what I have tried (among various other things):
>
> sub print_locations {
> my $locations;
> recurse ($root, \&append_location, \$locations);
^^^^^
This variable appears from out of the blue- why not pass it as
an argument?
[...rest looks ok to me...]
#!/usr/bin/perl -w
use strict;
sub print_locations {
my $locations;
recurse (shift, \&append_location, \$locations);
print $locations;
}
sub recurse {
my ($node, $subref, $param) = @_;
if ($node) {
$subref->($node, $param);
recurse ($node->{sub}, $subref, $param);
recurse ($node->{next}, $subref, $param);
}
}
sub append_location {
my ($node, $locations) = @_;
$$locations .= $node->{place};
}
my $root = {
place => "first",
sub => {
place => "second",
sub => undef,
next => {
place => "third",
sub => undef,
next => undef,
},
},
next => {
place => "fourth",
sub => {
place => "fifth",
sub => undef,
next => undef,
},
next => undef,
},
};
print_locations($root);
__END__
output:
firstsecondthirdfourthfifth
--
Joe Schaefer "Familiarity breeds contempt -- and children."
--Mark Twain
------------------------------
Date: Sun, 6 May 2001 07:41:04 +0200
From: "Samuel Kilchenmann" <skilchen@swissonline.ch>
Subject: Re: Passing references via recursion
Message-Id: <9d2orq$g1nf2$1@ID-13368.news.dfncis.de>
"Arvin Portlock" <temp133@hotmail.com> schrieb im Newsbeitrag
news:9d25ie$ait$1@agate.berkeley.edu...
> I'm using recursion on a tree to append data to a variable.
> I want to try and do it without using global variables. I can't
> seem to do it.
>
> Here's what I have tried (among various other things):
>
> sub print_locations {
> my $locations;
> recurse ($root, \&append_location, \$locations);
> print $locations;
> }
>
Joe Schaefer has already shown you that your code actually works if
you put something into $root. But i don't like in-out parameters (such
as \$locations) at all. Avoiding the in-out parameter and reusing the
code from you and Joe Schaefer that gives something like:
#!/usr/bin/perl -w
use strict;
sub print_locations {
my $root = shift;
my $locations =
recurse ($root, \&append_location);
print $locations;
}
sub recurse {
my ($node, $subref) = @_;
my $result = '';
if ($node) {
$result = $subref->($node);
$result .= recurse ($node->{sub}, $subref);
$result .= recurse ($node->{next}, $subref);
}
return $result;
}
sub append_location {
my ($node) = @_;
return "$node->{place} ";
}
my $root = {
place => "first",
sub => {
place => "second",
sub => undef,
next => {
place => "third",
sub => {
place => "third_sub",
sub => undef,
next => {
place => "third_sub_next",
sub => undef,
next => undef,
},
},
next => {
place => "third_next",
sub => {
place => "third_next_sub",
sub => undef,
next => undef,
},
next => undef,
}
},
},
next => {
place => "fourth",
sub => {
place => "fifth",
sub => undef,
next => undef,
},
next => undef,
},
};
print_locations($root);
__END__
output:
first second third third_sub third_sub_next third_next third_next_sub
fourth fifth
------------------------------
Date: Sun, 06 May 2001 01:28:32 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: removing the \n from the data obtained from a text area in a form
Message-Id: <3AF4A8BE.100D43B1@acm.org>
Benjamin Goldberg wrote:
>
> And what happens if he is running the script on win and the file being
> processed came from unix? Then that first <> will end up slurping in
> the whole file, unable to find any \r\n!
Actually, no it won't, Perl is "smart" enough to do the right thing with
either DOS or Unix text files on Windows, at least my version of Perl
is.
John
--
use Perl;
program
fulfillment
------------------------------
Date: Sun, 06 May 2001 05:27:42 GMT
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: System call within Daemon
Message-Id: <3AF4E1F5.444BE044@earthlink.net>
mxvera@qwest.com wrote:
>
> Greetings,
>
> I have written a forking socket server, but I need to start other
> daemonized programs with it. The programs are usually started with a
> little script which calls the main daemon, then the little script
> exits.
>
> The problem I have is that the daemon takes on the properties of my
> socket server such that if I kill the socket server, the socket is
> still in use by the program started by the original socket server.
> This is bad because to start the socket server again, I would need to
> kill the system call to free up the socket.
I assume you are refering to the listening socket, not the accepted
socket.
I'll also assume you are using IO::Socket.
my $server = new IO::Socket::INET(%params);
$SIG{CHLD} = 'IGNORE'; # This is important when using fork!
while( my $client = $server->accept() ) {
my ($sleep, $pid)=(1);
defined $pid = fork or die "Could not fork: $!";
if( $pid == 0 ) { # child
# we need a second fork to make us a daemon
defined $pid = fork or die "Could not refork: $!";
exit 0 if $pid != 0;
# **** It is very important to get rid of the child's
$server->close; # copy of the listening socket, or else
# **** you get the very same problems you seem to have.
# These lines make it so that system'd or exec'd
# programs can see the accepted socket.
my $fn = $client->fileno;
open STDIN, "<&=$fn";
open STDOUT, ">&=$fn";
# It *should* be set to close on exec, but I'm paranoid
$client->close;
# This should execute program1 then program2
system $programpath1, @args;
system $programpath2, @args;
exit;
# If we only have one program to execute, this is
# cheaper, since system does an extra fork and stuff.
#exec $programpath, @args;
#die "cannot exec '$programpath' $!";
} else { # parent
$client->close;
}
}
> I believe using exec() would solve this, however, I need to do more
> within the server after the system call, and it seems that exec()
> performs the system call, then skips anything following. I am fairly
> certain I don't know the proper way to implemet exec().
It's not exec that you need to solve the problem, it's closing the
appropriate sockets in the parent and child processes in the right order
after forking.
--
Shift to the left, shift to the right, mask in, mask out, BYTE, BYTE,
BYTE !!!
------------------------------
Date: 6 May 2001 00:55:40 GMT
From: hudson@swcp.com (Tramm Hudson)
Subject: The Canonical Program (was Re: I remember someone made a perl parser.)
Message-Id: <9d27ec$dum$1@sloth.swcp.com>
Keywords: troll, troll, troll
flash <bop@mypad.com> wrote:
> ... read the file and do stuff ...
Ah -- the canonical program:
int main( int argc, char *argv[] )
{
read_input();
do_stuff();
write_output();
}
The Perl version is similar:
#!/usr/bin/perl -w
use strict;
read_input();
do_stuff();
write_output();
__END__
Writing the read_input, do_stuff and write_output routines is left
as an exercise to the student. Be sure to enable warnings and the
strict pragma in any event.
What does this have to do with parsing Perl?
Tramm
--
o hudson@swcp.com hudson@turbolabs.com O___|
/|\ http://www.swcp.com/~hudson/ H 505.323.38.81 /\ \_
<< KC5RNF @ N5YYF.NM.AMPR.ORG W 505.986.60.75 \ \/\_\
0 U \_ |
------------------------------
Date: Sun, 06 May 2001 03:18:25 GMT
From: "flash" <bop@mypad.com>
Subject: Re: The Canonical Program (was Re: I remember someone made a perl parser.)
Message-Id: <5o3J6.20432$_f3.422738@news20.bellglobal.com>
well originally i wanted to parse a perl file.
but i found another way to do what i want.
"Tramm Hudson" <hudson@swcp.com> wrote in message
news:9d27ec$dum$1@sloth.swcp.com...
> flash <bop@mypad.com> wrote:
> > ... read the file and do stuff ...
>
> Ah -- the canonical program:
>
> int main( int argc, char *argv[] )
> {
> read_input();
> do_stuff();
> write_output();
> }
>
> The Perl version is similar:
>
> #!/usr/bin/perl -w
> use strict;
>
> read_input();
> do_stuff();
> write_output();
> __END__
>
> Writing the read_input, do_stuff and write_output routines is left
> as an exercise to the student. Be sure to enable warnings and the
> strict pragma in any event.
>
> What does this have to do with parsing Perl?
>
> Tramm
> --
> o hudson@swcp.com hudson@turbolabs.com O___|
> /|\ http://www.swcp.com/~hudson/ H 505.323.38.81 /\ \_
> << KC5RNF @ N5YYF.NM.AMPR.ORG W 505.986.60.75 \ \/\_\
> 0 U \_ |
------------------------------
Date: Sat, 5 May 2001 22:22:23 -0500
From: "Jimi Thompson" <JIMIT@prodigy.net>
Subject: Re: Using Modem::Vgetty
Message-Id: <9d2fqe$17ts$3@newssvr06-en0.news.prodigy.com>
You might try contacting the author of the module.
Perl Lover <dj@syntaxerror.crazydj.de> wrote in message
news:20010505.130043.1626276121.1249@Syntaxerror.crazydj.de...
> Im Artikel <9cvrhr$66d2$1@newssvr05-en0.news.prodigy.com> schrieb "Jimi
> Thompson" <JIMIT@prodigy.net>:
>
> > Have you tried www.freshmeat.net, www.sourceforge.com, and
> > http://www.cpan.org
> >
> Yes I have. But the only tool I found was opentel and I dont know how to
> use it...
------------------------------
Date: Sun, 06 May 2001 05:52:32 GMT
From: "flash" <bop@mypad.com>
Subject: What is the best module...
Message-Id: <AE5J6.56$2J5.3229@news20.bellglobal.com>
what is the best module to encrypt/decrypt text files?
everyone i have checked out can only encrypt 8 bits.
and i need to encrypt files over 2KB
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 841
**************************************