[12157] in Perl-Users-Digest
Perl-Users Digest, Issue: 5757 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun May 23 11:07:15 1999
Date: Sun, 23 May 99 08:00:17 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 23 May 1999 Volume: 8 Number: 5757
Today's topics:
[Fwd: XS programming (HELP!) newbie...] <emilio_tunon@nl.compuware.com>
Re: CGI/ISAPI problem <emilio_tunon@nl.compuware.com>
Re: Help with challenge script <gellyfish@gellyfish.com>
How can I "poll" the serial port ?? <ricklim@vcn.bc.ca>
Re: How can I "poll" the serial port ?? <abey@cs.ucr.edu>
Re: How can I "poll" the serial port ?? (Sam Holden)
Re: Mac-specific Perl help requested (Bart Lateur)
Re: Nested loop <gellyfish@gellyfish.com>
Re: Nested loop (Bob Trieger)
Re: Perl "constructors" <rra@stanford.edu>
Re: s/// (Bart Lateur)
Re: sorting ? <gellyfish@gellyfish.com>
Re: Sys::Syslog doesn't work in Perl5.005_03 :-( <gellyfish@gellyfish.com>
Re: using gethostbyaddr? <gellyfish@gellyfish.com>
Re: Using perl to port a telnet session to HTML <abey@cs.ucr.edu>
Re: wait(), zombies, and solaris: why won't my children (Peter McMorran)
XS help with references! <emilio_tunon@nl.compuware.com>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 23 May 1999 12:14:08 +0200
From: Didimo Emilio Grimaldo Tunon <emilio_tunon@nl.compuware.com>
Subject: [Fwd: XS programming (HELP!) newbie...]
Message-Id: <3747D4F0.45F80D1@nl.compuware.com>
This is a multi-part message in MIME format.
--------------9069EC8F3A049876FBD87CF4
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
--
__o "Admit nothing, deny everything, demand proof. :)"
_`\<,_ -James Ebbs
___(*)/_(*)____.___o____..___..o...________ooO..._____________________
D. Emilio Grimaldo Tunon
http://www.iaehv.nl/users/grimaldo/
http://www.iaehv.nl/users/grimaldo/cv/
http://www.iaehv.nl/users/grimaldo/panama.html
http://www.iaehv.nl/users/grimaldo/Linux/
--------------9069EC8F3A049876FBD87CF4
Content-Type: message/rfc822
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Path: news.IAEhv.nl!not-for-mail
From: Didimo Emilio Grimaldo Tunon <grimaldo@iaehv.nl>
Newsgroups: comp.lang.perl.modules
Subject: XS programming (HELP!) newbie...
Date: Sat, 22 May 1999 16:41:38 +0200
Organization: Internet Access Eindhoven, the Netherlands
Message-ID: <3746C222.6D3643F8@nl.compuware.com>
NNTP-Posting-Host: pm13d33.iae.nl
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Mailer: Mozilla 4.07 [en] (X11; I; Linux 2.0.36 i586)
Xref: news.IAEhv.nl comp.lang.perl.modules:23535
Hi XS*,
I am just beginning to get into Perl Extension programming (XS),
have read the various manual pages and have gotten something basic
working but I have the following questions:
1. The perlxstut man page says that during 'make install' it is
installed in the Perl's system directory (/usr/lib/perl5/...)
but what about being able to install it in 'user space'? say
$HOME/perllib/ ? is that possible? I would hope so, that way
one can try these binary modules before actually installing
them on the system (among other applications...)
2. I have a Perl function that I invoke like:
&SetRequest(\$var1, \@array, \%hash);
but I haven't figured out how to get the thing to either
let var1 be known to the caller or get elements (in the XS)
from the array. The array has strings.
Could somebody give me a short example of how to have the
proper XS stub for this function? what about getting the
string elements of the array? I figured out how to get the
length of the array but that's it :( and if it is not much
to ask (for the sake of an example) obtaining the key and
value of the hash. Both the array and the hash are actually
references-to..
I think that will give me a quick start, in the meantime
I will read the man pages again but I haven't found any
useful, practical example out of it...
TIA,
Emilio
--
__o "Admit nothing, deny everything, demand proof. :)"
_`\<,_ -James Ebbs
___(*)/_(*)____.___o____..___..o...________ooO..._____________________
D. Emilio Grimaldo Tunon
http://www.iaehv.nl/users/grimaldo/
http://www.iaehv.nl/users/grimaldo/cv/
http://www.iaehv.nl/users/grimaldo/panama.html
http://www.iaehv.nl/users/grimaldo/Linux/
--------------9069EC8F3A049876FBD87CF4--
------------------------------
Date: Sun, 23 May 1999 12:06:00 +0200
From: Didimo Emilio Grimaldo Tunon <emilio_tunon@nl.compuware.com>
Subject: Re: CGI/ISAPI problem
Message-Id: <3747D308.3445B540@nl.compuware.com>
Sharad Bansal wrote:
>
> Sorry, I can't help u with this. But, I have my own perl IIS issue . Did u try
> to redirect STDERR ? ie
> carpout(LOGG) ? IIS just gives an error witht this ...
>
> It very well might be that Carp and File have bugs under IIS.
>
> - Sharad
>
> Gunther Schmidl wrote:
>
> > I'm having huge troubles with below script (apart from the obvious bad
MS IIS has the annoying habit of swallowing stderr. That I
know the CGI docs say that whatever you send to stdout is meant
for the server, thus leaving you with stderr for the bad things.
It has been my experience so far that IIS also captures stderr
and merges it with stdout so both of them go back to your
browser. Very bad!. This is not the case with Apache.
Emilio
--
__o "Admit nothing, deny everything, demand proof. :)"
_`\<,_ -James Ebbs
___(*)/_(*)____.___o____..___..o...________ooO..._____________________
D. Emilio Grimaldo Tunon
http://www.iaehv.nl/users/grimaldo/
http://www.iaehv.nl/users/grimaldo/cv/
http://www.iaehv.nl/users/grimaldo/panama.html
http://www.iaehv.nl/users/grimaldo/Linux/
------------------------------
Date: 23 May 1999 10:31:54 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Help with challenge script
Message-Id: <7i8leq$4k6$1@gellyfish.btinternet.com>
On 23 May 1999 02:53:39 GMT anonymous wrote:
> Right now I have Matts wwwboard2.0a
> script
Please dont do that. As has been discussed at length here recently this
(ahem) 'program' is fundamentally flawed.
To summarize:
* It displays a total ignorance of the output of localtime and thus
will cease to function properly in six and a bit months time.
* It uses no locking on any of the files an thus will fail under
concurrent access.
* Either no checking of file opens is done or it simply dies in the
face of a problem with a file - giving 500 error to user.
* It uses a baroque and inefficient storage method - have you looked
in those message files - how much of that is identical in each ?
So no I am not inclined to help you with your problem. You would be
better off writing the whole thing yourself from scratch. Sorry if this
sounds harsh but I think it is better that we let this 'program' go off
and die in the wilderness and helping you will only help perpetuate it.
BTW please fix your newsreader so it wraps at an acceptable 75ish
characters rather than the 80+ that it does now. Thank you.
/J\
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 23 May 1999 05:16:02 GMT
From: Rick Lim <ricklim@vcn.bc.ca>
Subject: How can I "poll" the serial port ??
Message-Id: <7i82ui$apb$1@sylvester.vcn.bc.ca>
I have tried
open(SERIALPORT, "+>$Port");
then a
$sStringFromPort .= <SERIALPORT>;
but if there is no data in the serial port then
the program just blocks until something arrives.
what I would like to do is just poll the port and
if there is data then process it otherwise the program
carrys on, the idea is to send data to the serial port
and test for a response if not do some other process.
--
The wealth of reality, cannot be seen from your locality.
------------------------------
Date: Sun, 23 May 1999 07:57:29 -0700
From: Abraham Grief <abey@cs.ucr.edu>
To: Rick Lim <ricklim@vcn.bc.ca>
Subject: Re: How can I "poll" the serial port ??
Message-Id: <Pine.LNX.4.05.9905230750470.21607-100000@hill.cs.ucr.edu>
On 23 May 1999, Rick Lim wrote:
> I have tried
> open(SERIALPORT, "+>$Port");
> then a
> $sStringFromPort .= <SERIALPORT>;
> but if there is no data in the serial port then
> the program just blocks until something arrives.
> what I would like to do is just poll the port and
> if there is data then process it otherwise the program
> carrys on, the idea is to send data to the serial port
> and test for a response if not do some other process.
I've never tried it on a serial port, but if you're on some sort of Unix,
this might work:
sysopen(SERIALPORT, $Port, O_RDWR|O_NDELAY);
Hope this helps.
------------------------------
Date: 23 May 1999 14:58:21 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: How can I "poll" the serial port ??
Message-Id: <slrn7kg5sd.nis.sholden@pgrad.cs.usyd.edu.au>
On 23 May 1999 05:16:02 GMT, Rick Lim <ricklim@vcn.bc.ca> wrote:
>I have tried
>open(SERIALPORT, "+>$Port");
>then a
>$sStringFromPort .= <SERIALPORT>;
>but if there is no data in the serial port then
>the program just blocks until something arrives.
>what I would like to do is just poll the port and
>if there is data then process it otherwise the program
>carrys on, the idea is to send data to the serial port
>and test for a response if not do some other process.
perldoc -f select
--
Sam
If your language is flexible and forgiving enough, you can prototype
your belief system without too many core dumps.
--Larry Wall
------------------------------
Date: Sun, 23 May 1999 11:44:49 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Mac-specific Perl help requested
Message-Id: <374ee966.3201468@news.skynet.be>
Bob Trieger wrote:
>Knowing almost nothing about Mac, I think what you want to do is
>translate all of the \n and \r\n characters into \r or vice-versa.
>
>Winblows uses "\r\n" as a delimiter, Eunichs uses "\n" and Macintrash
>"\r"
Close. But "\n" and "\r" are platform dependent definitions. In short:
when converting anything to the native format, convert into "\n". You
never need "\r".
If you have the whole file in a scalar, this will work on a Mac):
s/\015?\012/\n/g;
If you split your file into chunks, you may encounter the case where the
CR and LF from a DOS-file are in different chunks, resulting in two
newlines on a Mac. Rare, but still possible.
Bart.
------------------------------
Date: 23 May 1999 10:54:31 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Nested loop
Message-Id: <7i8mp7$4la$1@gellyfish.btinternet.com>
On Sun, 23 May 1999 07:38:22 +0200 danfan wrote:
> I have failed to write a nested while-loop
> using perl 5.01 from NT reskit.
> Is it a bug or do i miss something?
Very possibly using that particular thing yes - a veritable flea-bitten
camel carcass and redmondware too - it has no modules no documentation
infact it is probably worse than no good.
Go straight away to <http://www.activestate.com> and download the lastest
build of ActivePerl before yu get into any more trouble.
> #!/usr/local/bin/perl
> $i = 0;
> $x = 0;
> while ( $i < 10 )
> {
> $i += 1;
> while ( $x < 10 )
> {
> $x +=1;
> print "$i $x \n" ;
> }
> }
Well the single logical problem with your code is that you are not resettting
the value of $x in the outer loop - you should do $x = 0 either before or
after the inner while otherwise it will never get to less than 10 again
and thus the inner loop will never be entered after the first time.
Now the stylistic matter - this of course could be written more neatly as:
#!/usr/bin/perl -w
use strict;
my ($inner,$outer);
for $outer ( 1 .. 10 )
{
for $inner ( 1 .. 10 )
{
print "$outer $inner\n";
}
}
(Note the use of -w and 'use strict' to keep you honest )
Or indeed:
#!/usr/bin/perl -w
use strict;
my $outer;
while ( $outer++ < 10 )
{
my $inner;
while ( $inner++ < 10 )
{
print "$outer $inner\n";
}
}
Note in this latter case $inner will not be available after the completion
of the outer loop.
You might look at the perlsyn manpage to find out about the C-Style
for as well (Oh sorry you dont have that do you - the documentation that is).
/J\
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Sun, 23 May 1999 13:01:50 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: Nested loop
Message-Id: <7i8smc$m8i$1@ash.prod.itd.earthlink.net>
[ courtesy cc sent by mail if address not munged ]
"danfan" <nfy339g@tninet.se> wrote:
>I have failed to write a nested while-loop
>using perl 5.01 from NT reskit.
>Is it a bug or do i miss something?
>/DG
>---------------------------------------------------------------------
>This code:
>#!/usr/local/bin/perl
Put a -w switch in that shbang line right now or I will kill a puppy!
>$i = 0;
>$x = 0;
>while ( $i < 10 )
>{
> $i += 1;
> while ( $x < 10 )
> {
> $x +=1;
> print "$i $x \n" ;
> }
>}
>generates:
>1 1
>1 2
>1 3
>1 4
>1 5
>1 6
>1 7
>1 8
>1 9
>1 10
It is doing exactly what you told it to do. It is printing while $x is
less than 10.
I think you meant to set $x to 0 inside the outer loop.
try this:
#!/usr/local/bin/perl -w
use strict;
for (my $i=0;$i<10;$i++) {
for (my $j=0;$j<10;$j++) {
print "$i $j\n";
}
}
HTH
------------------------------
Date: 23 May 1999 04:01:21 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Perl "constructors"
Message-Id: <yl1zg859tq.fsf@windlord.stanford.edu>
Kai Henningsen <kaih=7HPvvm5mw-B@khms.westfalen.de> writes:
> Every language has some things it's not suitable for. What I'm saying
> here is that few people would care if, for Perl, that included
> "long-running demons that MUST NOT, ever, die".
Given that Perl currently can't handle signals properly, Perl *already*
isn't a very good language for writing such things in.
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: Sun, 23 May 1999 11:40:08 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: s///
Message-Id: <374de74a.2661335@news.skynet.be>
Jody Fedor wrote:
>Is there better information on s/// than perldoc or "Pearl Programming"?
You did check out "perlop" for the modifiers and "perlre" for the
regexes, did you?
>Is there a place that has lots of examples and then explains what each one
>is and how it works?
Try the links on http://reference.perl.com/query.cgi?regexp in
particular the chapter from Effective Perl Programming in PDF, and the
article from Tom Christiansen, both links pretty near the bottom of the
page.
Bart.
------------------------------
Date: 23 May 1999 11:16:21 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: sorting ?
Message-Id: <7i8o25$4mg$1@gellyfish.btinternet.com>
On Sun, 23 May 1999 08:01:08 GMT tvn007@my-dejanews.com wrote:
> Hi,
>
> Would someone help me or give me some hint how to solve this problem ?
>
> Below is the problem:
>
> I have a file as follow (just small sample for demo. ):
>
<snip>
>
> I would like to output sorted as follow:
> (since FILE fyx has only one line of CODE I would line to put it first)
> (since FILE abc has two line of CODE I would like to put second )
> (since FILE xyc has three line of CODE I would like to put it third)
>
OK I'll bite :
#!/usr/bin/perl -w
use strict;
my %records;
my $key;
while(<DATA>)
{
chomp;
if (/FILE/)
{
$key = $_
}
else
{
push @{$records{$key}},$_
}
}
my @order = map { $_->[0] }
sort { $a->[1] <=> $b->[1] }
map { [ $_, scalar @{$records{$_}} ] }
keys %records;
foreach (@order )
{
print $_,"\n";
my $record;
foreach $record (@{$records{$_}} )
{
print $record,"\n";
}
}
__END__
FILE: abc
CODE xcc sds H
CODE xcdaa sds L
FILE: xyc
CODE uics sds H
CODE xcd sds X
CODE xcoi sds L
FILE fyx
CODE xcc sds H
Thats my take on it anyhow - it probably isnt the best way but there you
go. Basically what is happening here is that each CODE line is being
pushed onto an array a reference to which is held in the hash keyed on
the FILE line. Then the STish thing creates an array that has these
keys in order of the number of values in those arrays (the scalar @{ bit ).
The rest I hope is obvious.
Anyhow I'm sure that someone (they know who they are :) will be along
in a while with a far more elegant solution ...
/J\
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 23 May 1999 10:07:13 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Sys::Syslog doesn't work in Perl5.005_03 :-(
Message-Id: <7i8k0h$4jv$1@gellyfish.btinternet.com>
[ The useless alt.perl & alt.perl.sockets removed - I would have done
earlier but didnt notice ]
In comp.lang.perl.misc Arjun Ray <aray@nmds.com> wrote:
> In <7i60hj$1cu$1@gellyfish.btinternet.com>,
> Jonathan Stowe <gellyfish@gellyfish.com> wrote:
> | In comp.lang.perl.misc Ingo Ciechowski <ciechowski@cis-computer.com> wrote:
>
> | > I've got a problem using the Sys::Syslog package on my linux 2.0.36
> | > system with Perl Perl5.005_03...
>
> There's also a problem with RedHat 5.x distributions and 5.004_04.
> (More on this below.)
>
> | There was a thread recently on this subject and the code that was
> | that to work goes something like this :
>
> (As a general comment on a parallel strand, using UNIX domain sockets
> is the correct approach. Blindly launching 'syslogd -r' is *not* a
> good idea. The syslogd man page may have details on how this makes
> some denial of service attacks possible, the workarounds for which may
> be more trouble than the "convenience" of INET sockets are worth.)
>
Though some people do use a loghost on their network in order to have all
the messages logged to the same place - I agree with you in principal
though - it is not necessary to do this just to log to localhost.
> | #!/usr/bin/perl -w
> | use strict;
> | use Sys::Syslog qw(openlog syslog setlogsock closelog);
>
> Unfortunately, setlogsock is not exported by Sys::Syslog, so
>
> | setlogsock('unix');
>
> Has to be
>
> : Sys::Syslog::setlogsock('unix') ;
>
> After which, yes, the code works fine.
>
No. That is why I have explicitly imported the functions there. I
mentioned that there was some wierdness with the exporter in regard
to this module - but this code run fine for me under strict without
the need to fully qualify the function.
Whilst I dont want to seem glib - I think that this problem (and the
other stuff which I am not going to comment on ) will go away if you
upgrade your Perl to 5.005.0[23].
> However, just to get this far, I first had to contend with a compile
> time error. Specifically:
>
I dont feel qualified to comment on the problem with stdarg.ph I'm afraid.
/J\
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 23 May 1999 09:55:18 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: using gethostbyaddr?
Message-Id: <7i8ja6$4jg$1@gellyfish.btinternet.com>
On 22 May 1999 23:15:41 GMT Chuck Bearden wrote:
> On Tue, 18 May 1999 20:41:12 -0700, Larry Rosler <lr@hpl.hp.com> wrote:
>>[Posted and a courtesy copy sent.]
>>
>>In article <3741E75B.7F6E41C4@infonet.ee> on Wed, 19 May 1999 01:19:07
>>+0300, Gleb Ekker <globus@infonet.ee> says...
>>>
>>> I heared that it is possible to modify it by using gethostbyaddr, to
>>> resolve the host address into a host name. Please give me an example how
>>> I can do this thing.
>>
>>There is an example in the Perl documentation of the function.
>>
>>perldoc -f gethostbyaddr
>>
>
> This is a timely posting, as I'm having trouble making 'gethostbyaddr'
> work, and unfortunately, 'perldoc -f gethostbyaddr' does not include
> an example on my system (RH Linux 5.2, perl-5.004m4-1.src.rpm). I am
> downloading the updated RPM as I compose this message.
>
> I can gethostbyname just fine:
>
<snip>
>
> However, the inverse doesn't seem to work:
>
> $addr = "204.52.135.1";
> @addr = split(/\./, $addr);
> $addr = pack('C4', @addr);
> #print length($addr), "\n";
> $name = gethostbyaddr($addr, AF_INET);
>
> gives an error:
>
> Argument "AF_INET" isn't numeric in ghbyaddr at ./getbyaddr line 7.
> Use of uninitialized value at ./getbyaddr line 9.
>
If you had used 'strict' you would have got another warning which might have
given you another clue as well:
Bareword "AF_INET" not allowed while "strict subs" in use at blarg.pl line 8.
To use the constant AF_INET in your code you will need to :
use Socket;
Otherwise you will need to refer to the file /usr/include/sys/socket.h
(or whatever file holds the definitions /usr/linclude/linux/socket.h here):
#define AF_UNIX 1 /* Unix domain sockets */
#define AF_LOCAL 1 /* POSIX name for AF_UNIX */
#define AF_INET 2 /* Internet IP Protocol */
#define AF_AX25 3 /* Amateur Radio AX.25 */
#define AF_IPX 4 /* Novell IPX */
#define AF_APPLETALK 5 /* AppleTalk DDP */
#define AF_NETROM 6 /* Amateur Radio NET/ROM */
...
And supply the appropriate value (2 in this case ).
whilst you are at it you might also consider using inet_aton instead of
your split/pack - this is documented in the Socket.pm manpage:
inet_aton HOSTNAME
Takes a string giving the name of a host, and
translates that to the 4-byte string (structure).
Takes arguments of both the 'rtfm.mit.edu' type and
'18.181.0.24'. If the host name cannot be resolved,
returns undef. For multi-homed hosts (hosts with more
than one address), the first address found is
returned.
/J\
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Sun, 23 May 1999 05:51:27 -0700
From: Abraham Grief <abey@cs.ucr.edu>
To: Hawkwynd <hawkwynd@adelphia.net>
Subject: Re: Using perl to port a telnet session to HTML
Message-Id: <Pine.LNX.4.05.9905230542020.21263-100000@hill.cs.ucr.edu>
On Thu, 20 May 1999, Hawkwynd wrote:
> I'm working on a script that (so far) can telnet to a SMAUG mud server, and
> perform commands on the server as if it were a human working on the server.
>
> Using the following commands, I can get the script to write commands, and do
> waitfor's but I need to be able to access the outout and retreive the
> information from the server when it is displayed to the script.
> # wait for ready prompt, and perform USERS to list users currently online
> $t->waitfor('/]/');
> $t->print("users\n");
>
>
> # Do same, except perform WHO
> $t->waitfor('/]/');
> $t->print("who\n");
>
>
> It is here that I need to capture the output of the server's response
> and save it to file, or update the HTML page to reflect the users online.
>
> Any help with this is GREATLY APPRECIATED!
This should hopefully get the output of the who command and save it to a
file called "whooutput", if put in the place of the $t->print("who\n")
statement:
my @lines = $t->cmd('who');
open(WHO, ">whooutput") or die("Cannot open whooutput: $!");
print WHO @lines;
close(WHO) or die("Cannot close whooutput: $!");
I haven't tested this, so I hope it works and doesn't have any syntax
errors that I don't see. Hope this helps.
------------------------------
Date: Sun, 23 May 1999 10:07:38 -0400
From: mcmorran@norfolk.infi.net (Peter McMorran)
Subject: Re: wait(), zombies, and solaris: why won't my children die?
Message-Id: <37480c5f$1$zpzbeena$mr2ice@news.norfolk.infi.net>
In <slrn7k8fsh.p75.charlie@cs.ed.datacash.com>, on 05/20/99
at 04:59 PM, charlie@antipope.org (Charlie Stross) said:
>Is there something really weird about the way SIGCHILD is
>handled on Solaris? A preliminary look at the manpages suggests
>that there's a lot of extra information transmitted with
>signals, and I'm scratching my head over where to begin.
Yes. Signal handlers on Solaris only fire once. So, you need some
trickery to cause the handler to re-establish itself for the next
signal. Otherwise, the second SIGCHILD will take you down. This
should be in the FAQs or docs, since it's such a common
annoyance.
Cheers,
Peter
--
-----------------------------------------------------------
mcmorran@norfolk.infi.net (Peter McMorran)
-----------------------------------------------------------
------------------------------
Date: Sun, 23 May 1999 12:28:39 +0200
From: Didimo Emilio Grimaldo Tunon <emilio_tunon@nl.compuware.com>
Subject: XS help with references!
Message-Id: <3747D857.E597C78A@nl.compuware.com>
Hi *,
I am a Perl XS newbie and am exploring the concept. Having
read ALL the man pages I found that none actually answered my
questions (typical textbook problem) so here it is.
I want to implement an extension function which takes three
references (scalar, array, hash) for the purpose of asking
everything in one example. The function not only accesses the
strings in the parameters but also modifies them. From
Perl:
&myFunction( \$scalar, \@array, \%hash);
now, how on XS how would I:
1. Declare the three input parameters, all three are
references, that I didn't find in the manual page.
2. How do I access the string withing the 'scalar'
reference, and the strings within the 'array' reference?
3. How do I query a particular key of the 'hash' reference?
what about the value?
4. Modifying the referenced scalar, array, hash?
Well, that would get me started, I have tried many things and
only get a core dump.
TIA,
Emilio
--
__o "Admit nothing, deny everything, demand proof. :)"
_`\<,_ -James Ebbs
___(*)/_(*)____.___o____..___..o...________ooO..._____________________
D. Emilio Grimaldo Tunon
http://www.iaehv.nl/users/grimaldo/
http://www.iaehv.nl/users/grimaldo/cv/
http://www.iaehv.nl/users/grimaldo/panama.html
http://www.iaehv.nl/users/grimaldo/Linux/
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 5757
**************************************