[7065] in Perl-Users-Digest
Perl-Users Digest, Issue: 690 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 1 18:07:13 1997
Date: Tue, 1 Jul 97 15:00:28 -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 Tue, 1 Jul 1997 Volume: 8 Number: 690
Today's topics:
5.00401 segfault on Solaris (Jeff Stampes)
Re: Anomaly in regexp handling (Ilya Zakharevich)
C to Perl socket communication question (Carl Swanson)
converting relative paths to real paths in webpage? (Calle ]sman)
Re: dir tree search (Ilya Zakharevich)
Re: dir tree search <clark@s3i.com>
Re: Empty loops... (Craig Berry)
Re: EMULATING 'C' STRUCTURES (Jay Flaherty)
Re: Finding modified files (was Re: recursive) (M.J.T. Guy)
Re: Finding modified files (was Re: recursive) <pdcawley@aladdin.net>
Re: Forcing a browser auth w Perl (Bill Totten)
Forking process doesn't recognize EOF <patzel@happy.informatik.uni-ulm.de>
hashes of hashes in perl5 <ivar.hosteng@merkantildata.com>
Re: hashes of hashes in perl5 <sfairey@adc.metrica.co.uk>
help with libwww <ahs+@andrew.cmu.edu>
Re: How can I debug a CGI script? <alastair@net7.co.uk>
Re: Looking for text indexing scripts/modules <sfairey@adc.metrica.co.uk>
Net::NNTP missing newsgroups? (Scott Thomason)
Perl CGI scripts getting slower...and...slower.. <alastair@net7.co.uk>
Re: Perl: deleting spaces etc in strings (John C. Randolph)
Re: Perl: How to delete spaces from an value/element in <sfairey@adc.metrica.co.uk>
Re: TimeSorting <sfairey@adc.metrica.co.uk>
Re: TimeSorting (Jean-Damien Durand)
When was PERL created? tim@hcirisc.cs.binghamton.edu
Re: Y2K and Perl (was Re: Y2K problems??) (M.J.T. Guy)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 1 Jul 1997 20:09:51 GMT
From: stampes@xilinx.com (Jeff Stampes)
Subject: 5.00401 segfault on Solaris
Message-Id: <5pbo6f$ag1$1@neocad.com>
I've installed DB 1.86 and perl5.00401 locally to see if it will
meet some of our needs, along with MLDBM. (output of perl -V
follows).
This is on Solaris 5.5.
I ahve built a database and have written my first attempts at
extracting the data. The script works, but Seg faults when it
is done. Any suggestion from people appreciated.
Extraction Script:
#!/home/stampes/perl5.004/bin/perl
use File::Find;
use MLDBM qw(DB_File);
use Fcntl;
local $testbed = tie %testbed, MLDBM, '/home/stampes/tmp/testbed', O_CREAT|O_RDWR, 0640 or die $!;
$tmp = $testbed{'SIT'};
while (($family,$scripts) = each %{$tmp})
{
while (($script,$designs) = each %$scripts)
{
while (($design,$chars) = each %$designs)
{
while (($key,$value) = each %$chars)
{
if (($key eq 'package') && ($value eq 'pc84')) {print "$design\n"}
}
}
}
}
undef $tmp;
undef $scripts;
undef $designs;
undef $chars;
undef $testbed;
untie %testbed;
output of perl -V:
Summary of my perl5 (5.0 patchlevel 4 subversion 1) configuration:
Platform:
osname=solaris, osvers=2.5, archname=sun4-solaris
uname='sunos fappy 5.5 generic sun4m sparc sunw,sparcstation-20 '
hint=recommended, useposix=true, d_sigaction=define
bincompat3=y useperlio= d_sfio=
Compiler:
cc='gcc', optimize='-O', gccversion=2.5.4
cppflags='-I/usr/local/include -I/home/stampes/downloads/db.1.86/PORT/sunos.5.2/include'
ccflags ='-I/usr/local/include -I/home/stampes/downloads/db.1.86/PORT/sunos.5.2/include'
stdchar='unsigned char', d_stdstdio=define, usevfork=false
voidflags=15, castflags=0, d_casti32=define, d_castneg=define
intsize=4, alignbytes=8, usemymalloc=y, randbits=15
Linker and Libraries:
ld='gcc', ldflags ='-L/home/stampes/downloads/db.1.86/PORT/sunos.5.2'
libpth=/usr/local/lib /lib /usr/lib /usr/ccs/lib /home/stampes/downloads/db.1.86/PORT/sunos.5.2
libs=-lsocket -lnsl -ldb -ldl -lm -lc -lcrypt
libc=/lib/libc.so, so=so
useshrplib=false, libperl=libperl.a
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=, ccdlflags=' '
cccdlflags='-fpic', lddlflags='-G -L/home/stampes/downloads/db.1.86/PORT/sunos.5.2'
Characteristics of this binary (from libperl):
Built under solaris
Compiled at Jun 27 1997 16:13:53
@INC:
/home/stampes/perl5.004/lib/sun4-solaris/5.00401
/home/stampes/perl5.004/lib
/home/stampes/perl5.004/lib/site_perl/sun4-solaris
/home/stampes/perl5.004/lib/site_perl
.
--
Jeff Stampes -- Xilinx, Inc. -- Boulder, CO -- jeff.stampes@xilinx.com
------------------------------
Date: 1 Jul 1997 20:30:10 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Anomaly in regexp handling
Message-Id: <5pbpci$n0t@agate.berkeley.edu>
In article <01bc8562$556a4b90$457985cd@falcon>,
Gabe Schaffer <gabe@gabe.com> wrote:
> Can somebody please either confirm or deny that this is the correct behavior?
>
> 'cdcde'=~/(c(d|e)+)+/;
> print qq('$1', '$2'\n);
>
> has the output "'cde', ''", even though...
This bug is corrected in the jumbo RE patch (on CPAN).
Ilya
------------------------------
Date: 1 Jul 1997 11:47:13 GMT
From: cswanson@pentagon.io.com (Carl Swanson)
Subject: C to Perl socket communication question
Message-Id: <5paqo1$1su$1@nntp-2.io.com>
I was wondering if someone might have a few ideas:
I am trying to get a C based client to speak to a Perl based server.
The C client is on a UNIX platform called QNX and the Perl server is
on an HP. I use the standard socket communication commands for both
sides (I will detail them below) but although the Perl server says the C
client is connected and that it is listening, when the C client does
a send to the Perl server, the Perl server never unblocks or hears it.
Now, I do have a Perl client and Perl server working, and I do have a
C client and C server working, so I know basically my setup and such is
correct on both sides.
So I guess my big question is: What would prevent the C lient and Perl
server from communicating properly, and why would the Perl server
never "wake up" and receive the socket send? Do I have to be
careful with configuring the sockets properly?
(Just as a note: I do a netstat on the server side and it says
that there is NOT anything waiting to be received on that socket).
Here is some of the code I use (I stripped a lot, but everything important
is still here). I know it's a little long, but I really would
appreciate any help someone could provide me.
Thank you so much!
Carl
cswanson@io.com
***************************************************
********************* C client *********************
***************************************************
struct hostent *HostInf; /* Pointer to info for remote host */
struct servent *ServInf; /* Pointer to service information */
struct sockaddr_in LocalAddr; /* Local socket address */
struct sockaddr_in PeerAddr; /* Remote socket address */
ConnectSocket()
{
/* Setup hostname info */
PeerAddr.sin_family = AF_INET;
HostInf = gethostbyname ("galaxy"); /* machine name */
PeerAddr.sin_addr.s_addr = ((struct in_addr
*)(HostInf->h_addr))->s_addr;
/* Setup service info */
ServInf = getservbyname ("testsocket", "tcp"); /* connection port in
/etc/services as 7020 */
PeerAddr.sin_port = ServInf->s_port;
/* Create socket */
Socket = socket (AF_INET, SOCK_STREAM, 0);
/* Connect socket */
if (connect(Socket, (void*)&PeerAddr, sizeof(struct sockaddr_in)) ==
-1) {
printf("CCemsrelay: unable to connect to remote\n"); exit(1);
}
/* Get local socket port info */
addrlen = sizeof(struct sockaddr_in);
if (getsockname(Socket, (void*)&LocalAddr, &addrlen) == -1) {
printf("CCemsrelay: unable to read socket address\n");
exit(1);
}
if (Socket) setsockopt (Socket, SOL_SOCKET, SO_KEEPALIVE, 0, 0);
if (Socket) setsockopt (Socket, IPPROTO_TCP, TCP_NODELAY, (char*) &opt,
sizeof(int));
printf("Connected to %s on port %u\n",HostName,ntohs(LocalAddr.sin_port));
return (0);
}
main (int argc, char **argv)
{
SINT command_len, sent_len;
STRING_80 command_line;
strcpy (TCPHostName, "odin");
strcpy (TCPServiceName, "testsocket");
ConnectSocket();
/* Receive and Relay messages until QUIT message */
while (!Quit) {
printf("\nCmd>");
command_len=getline(command_line, 80);
if (strcmp(command_line, "ETR") == 0){
sent_len = send(Socket, command_line, strlen(command_line), 0);
printf ("SENT LENGTH: %d\n", sent_len);
}
exit (0);
}
***********************************************************
********************* PERL SERVER ********************
***********************************************************
#!/usr/local/bin/oraperl
# MAIN PROCEDURE
use Port;
$myport = Port->new("INET_STREAM", "s", "testsocket");
if (! $myport->{transport}{connected} ) {
print $myport->{transport}{error_msg}. "\n";
exit;
}
print "Socket Open\n";
while (1) {
print "Trying to receive a message...\n";
my $from = $myport->get(\$buffer);
print "Received a message: $buffer!!!!\n";
# SUPPORT PROCEDURE TO OPEN SOCKET
use Socket;
$SOCK_TEMPL = 'n n a4 x8';
sub new {
my ($class, $sock_type, $service, $host) = @_;
my $obj = bless {
"port_handle" => "", "file_nbr" => -1,
"file_mask" => "", "sock_type" => $sock_type,
"sock_service" => $service, "sock_host" => $host,
"connected" => 0, "error" => 0,
"error_msg" => "",
};
my ($dmy, $proto);
($dmy, $dmy, $proto) = getprotobyname('tcp');
($dmy, $dmy, $service) = getservbyname($service, 'tcp') unless $service
=~ /^\d+$/;
my $templ = $Port_INET_STREAM::SOCK_TEMPL;
my $server_addr = pack($templ, AF_INET, $service, "\0\0\0\0");
my $TCP_NODELAY = 1;
if (! $Port_INET_STREAM::SERVER_OPEN) {
if ( socket(SERVER_SOCK, AF_INET, SOCK_STREAM, $proto) ) {
setsockopt (SERVER_SOCK, SOL_SOCKET, SO_REUSEADDR, 1) || die;
setsockopt (SERVER_SOCK, $proto, $TCP_NODELAY, 1) || die;
setsockopt (SERVER_SOCK, SOL_SOCKET, SO_RCVBUF, 30000) || die;
setsockopt (SERVER_SOCK, SOL_SOCKET, SO_SNDBUF, 30000) || die;
if ( bind(SERVER_SOCK, $server_addr) ) {
if ( listen(SERVER_SOCK, 5) ) {
my $oldfh = select(SERVER_SOCK); $| = 1; select($oldfh);
setsockopt (SERVER_SOCK, $proto, $TCP_NODELAY, 1) || die;
$Port_INET_STREAM::SERVER_OPEN = 1;
} } } }
if (! $Port_INET_STREAM::SERVER_OPEN) { return 0; }
my $handle = "Port_INET_STREAM::fh". $next_file_nbr++;
if ( accept($handle, SERVER_SOCK) ) {
my $oldfh = select($handle); $| = 1; select($oldfh);
setsockopt ($handle, $proto, $TCP_NODELAY, 1);
setsockopt ($handle, SOL_SOCKET, SO_RCVBUF, 30000);
setsockopt ($handle, SOL_SOCKET, SO_SNDBUF, 30000);
$this->{port_handle} = $handle;
$this->{file_nbr} = fileno($handle);
vec($this->{file_mask}, $this->{file_nbr}, 1) = 1;
$this->{connected} = 1;
$this->{sock_host} = "localhost";
$this->{sock_service} = $service;
$this->{error} = "";
$this->{error_msg} = "";
}
return $this->{connected};
}
sub get {
-- SNIP --
my $tot_read = 0;
$tot_read += read $handle, $$buffer, $len;
while ($tot_read < $len) {
$tot_read += read $handle, $$buffer, $len;
-- SNIP --
return $this->{sock_host}. ":". $this->{sock_service};
}
------------------------------
Date: 01 Jul 1997 11:44:05 +0200
From: md4calle@scooter.mdstud.chalmers.se (Calle ]sman)
Subject: converting relative paths to real paths in webpage?
Message-Id: <w7pk9jbqf8a.fsf@scooter.mdstud.chalmers.se>
Hi, I'm having problem converting realtive paths to real paths:
e.g. if you've retrieved a page: http://www.dummy.se/dir/index.html
and want to get all links, if the html looks something like:
<a href="link.html">link</a> in the document I want it to become:
<a href="http://www.dummy.se/dir/link.html">link</a>
everything works fine if the user enters an URL that ends with a /
e.g. http://www.dummy.se/dir/
but if the user types in, http://www.dummy.se/dir
it will get all messed up, and the link woul dbecome:
<a href="http://www.dummy.se/link.html">link</a>
anyone having experience in this?
/Calle
**************************************************************************
* * My homepage about the author Tom Holt: *
* /_\ http://www.mdstud.chalmers.se/~md4calle/holt/ *
* { ~._.~ } *
* ( Y ) other things like OnLine Guitar Archive linkpage *
* ( )~*~( ) and heaps of musiclinks can be found at *
* (__)-(__) http://www.mdstud.chalmers.se/~md4calle/ *
**************************************************************************
------------------------------
Date: 1 Jul 1997 20:32:57 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: dir tree search
Message-Id: <5pbphp$n26@agate.berkeley.edu>
In article <01bc85ab$caea8440$658667cf@rferr.voicenet.com>,
rferr <rferr@voicenet.com> wrote:
> are there any scripts available (or how would it be done) that read an
> entire directory
> tree structure file by file and search for a string in each file ?
Even taking into account what the other guys wrote, *most probably*
what you want is pfind (`find' with Perl syntax/semantics), available
from CPAN in my section.
Ilya
------------------------------
Date: 01 Jul 1997 08:06:31 -0400
From: Clark Dorman <clark@s3i.com>
Subject: Re: dir tree search
Message-Id: <d90zrm0xk.fsf@s3i.com>
"rferr" <rferr@voicenet.com> writes:
> are there any scripts available (or how would it be done) that read an
> entire directory
> tree structure file by file and search for a string in each file ?
>
> thanks.
Find a copy of Programming Perl (the first edition, the Red [Purple,
really] one). There on page 12 is what you are looking for. But,
since it may be hard to find here it is:
#!/home/dorman/bin/perl
# /home/stu/gnu/bin/perl
# /usr/local/bin/perl
# from p.12 of PROGRAMMING PERL (Larry Wall and Randal L. Schwartz)
# This routine prints filename if file contains a word on command line
# It descends recursively
open(FIND, "find . -print |") || die "Couldn't run find: $!\n";
FILE:
while($filename=<FIND>) {
chop $filename;
next FILE unless -T $filename;
if (!open(TEXTFILE, $filename)) {
print STDERR " Can't open $filename--continuing...\n";
next FILE;
}
while (<TEXTFILE>) {
foreach $word (@ARGV) {
if(index($_,$word) >= 0) {
print $filename, "\n";
next FILE;
}
}
}
}
__END__
Question for the perlers out there, shouldn't that be:
while( defined ( $filename=<FIND>) ) {
or is that done implicitly?
--
Clark Dorman "Evolution is cleverer than you are."
http://cns-web.bu.edu/pub/dorman/D.html -Francis Crick
------------------------------
Date: 1 Jul 1997 20:36:15 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Empty loops...
Message-Id: <5pbpnv$lc$1@marina.cinenet.net>
Randal Schwartz (merlyn@stonehenge.com) wrote:
: >>>>> "Craig" == Craig Berry <cberry@cinenet.net> writes:
:
: Craig> 1 while (...);
:
: The nice thing about this particular idiom is that you don't even need
: those parens:
:
: 1 while some-expr-that-you-want-done-and-the-truth-value-tested;
Please, let an old C hacker maintain at least a *few* shreds of his
treasured cultural heritage.
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: 1 Jul 1997 13:01:42 GMT
From: fty@hickory.engr.utk.edu (Jay Flaherty)
Subject: Re: EMULATING 'C' STRUCTURES
Message-Id: <5pav3m$od5$1@gaia.ns.utk.edu>
Doug Seay (seay@absyss.fr) wrote:
: Ansa Sekharan wrote:
: >
: > HOW DO I EMULATE THIS STRUCTURE IN PERL.. IN OTHER
: > WORDS HOW CAN I WRITE THE SAME STRUCTURE IN PERL
: > AND PASS IT TO A FUNCTION...
: >
: You don't bother reading much of the documentation, do you? Start by
: reading the perldata man page (perldoc perldata). AND PLEASE TURN OFF
: YOUR KEY CAPS.
Hi Ansa,
I hope you don't think we are all as rude as doug. I too have been
wondering how to emulate a C struc in Perl. Take a look at chap. 4
of the Camel book (Programming Perl), especially pg 272-275 (more
elaborate records) in a word, there is no direct emulation due to the
different nature of both languages but you should be able to devise
an algorithm that works using lists of lists notation.
Good luck...Jay
--
**********************************************
Jay Flaherty fty@utk.edu
If software was free, who would pay "THE BILL"
**********************************************
-----BEGIN PGP SIGNATURE-----
Version: 2.6.2
iQCVAwUBM2jQn1OdOzizdT/5AQHaWwP/bECLFr26GWHmszDuKUXCABW9cBuhqD9z
+JrJY+jRxF8yiV8ofkbma2vXi833RFDOz4vWZRetmjSV46MiDv5xzUatjyJnr57m
DadIYs9h0geGS6WOhJyy9dRI+YqQreQRa0QUW6NhYjdJJSrN/naYhPOfgS1mGhHX
P0RIJXP5JKI=
=edAe
-----END PGP SIGNATURE-----
------------------------------
Date: 1 Jul 1997 09:24:34 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Finding modified files (was Re: recursive)
Message-Id: <5paici$js@lyra.csx.cam.ac.uk>
Piers Cawley <pdcawley@aladdin.net> wrote:
>Hmm... speaking of using Find::File, has anyone got a neater way of
>doing the following:
>
>### Begin Code Fragment
>
># This sub will /only/ be called in an eval, Hence the die.
>$wanted = sub {
> return unless -f $_;
> $full{$home} = 1;
> if (-M _ <= $last_visit or $last_visit == 0) {
> $updated{$home} = 1;
> die "Found one\n";
> }
>};
>
>
>foreach $directory (@DIRECTORIES) {
> $@ = undef;
> my $old_die = $SIG{__DIE__};
> $SIG{__DIE__} = undef;
>
> eval {
> find($wanted, $home);
> };
> $SIG{__DIE__} = $old_die;
>
> if ($@) {
> die unless $@ =~ /^Found one/;
> }
>}
>
>### End code fragment.
i) It's simpler to localise $SIG{__DIE__} rather than save/restore.
ii) You don't need to unset $@ - $@ is always set null or non-null
by eval.
iii) I regard it as better practice to set an explicit flag rather than
test the syntax of the die argument.
So my version would be (untested code):
### Begin Code Fragment
# This sub will /only/ be called in an eval, Hence the die.
my $flag;
$wanted = sub {
return unless -f $_;
$full{$home} = 1;
$flag = (-M _ <= $last_visit or $last_visit == 0) &&
$updated{$home} = 1 &&
die "Won't see this\n";
}
};
foreach $directory (@DIRECTORIES) {
{ local $SIG{__DIE__};
eval {
find($wanted, $home);
};
};
die if $@ and not $flag;
}
### End code fragment.
Mike Guy
------------------------------
Date: 01 Jul 1997 11:56:21 +0100
From: Piers Cawley <pdcawley@aladdin.net>
Subject: Re: Finding modified files (was Re: recursive)
Message-Id: <54g1tzniqy.fsf@gunnar.aladdin.net>
mjtg@cus.cam.ac.uk (M.J.T. Guy) writes:
> Piers Cawley <pdcawley@aladdin.net> wrote:
> >Hmm... speaking of using Find::File, has anyone got a neater way of
> >doing the following:
> >
[...]
> >
> >### End code fragment.
>
> i) It's simpler to localise $SIG{__DIE__} rather than
> save/restore.
I could swear I tried that and it failed, but on checking again, I
appear to be wrong about that. Thanks.
> ii) You don't need to unset $@ - $@ is always set null or non-null
> by eval.
Thought so, wasn't sure.
> iii) I regard it as better practice to set an explicit flag rather than
> test the syntax of the die argument.
That makes sense certainly. Since I'm already setting updated{$home}
only if I'm about to crash out of the loop then presumably I don't
even need an explicit $flag (except for clarity of code of course).
> So my version would be (untested code):
>
> ### Begin Code Fragment
>
> # This sub will /only/ be called in an eval, Hence the die.
> my $flag;
> $wanted = sub {
> return unless -f $_;
> $full{$home} = 1;
> $flag = (-M _ <= $last_visit or $last_visit == 0) &&
> $updated{$home} = 1 &&
> die "Won't see this\n";
> }
> };
>
> foreach $directory (@DIRECTORIES) {
> { local $SIG{__DIE__};
> eval {
> find($wanted, $home);
> };
> };
>
> die if $@ and not $flag;
> }
Thanks, that works very well indeed. (Although for the purposes of
minimizing parentheses I moved the 'local $SIG{__DIE__}' part inside
the eval.
--
Piers Cawley -- Systems Genie for Aladdin
If a `religion' is defined to be a system of ideas that contains
unprovable statements, then Godel taught us that mathematics is not
only a religion, it is the only religion that can prove itself to be
one. -- John Barrow
------------------------------
Date: 1 Jul 1997 16:11:43 -0400
From: biell @ udel . edu (Bill Totten)
Subject: Re: Forcing a browser auth w Perl
Message-Id: <5pbo9v$ff1$1@copland.udel.edu>
In article <5p1bjs$ll7@nebula.is.rpslmc.edu>,
Daniel G. Drumm <dgd@nebula.is.rpslmc.edu> wrote:
>I'm searching for a way to force a browser to authenticate, as with a httpd
>protected page, strictly from within Perl.
I hacked a way to do this on my server. I do not like it all that much,
but it works. If my employer wanted a better solution, however, they would
have given me a UNIX box to work from instead of the NT crap I have to
work with. My implementation may only work on the brain dead M$IIS, because
of the way they force everything to go through the OS. The only good thing
the server does for this task is to not send the "HTTP/1.0 OK" line, because
I need to send an error message.
Basically, what I do is make the cgi executable by everyone, then have it
try to open a file which only a certain users have permissions to open. I
wanted to use stat instead of open, but NT sucks. If you can open the
file, then you must have already authenticated. if you cannot open the file,
it will force you to authenticate. Just put "&authenticate;" at the top of
your cgi-bin script. Here is the code:
$ip="xxx.xxx.xxx.xxx"; #IP of server
sub authenticate {
if(open(F, ".access")) {
close(F);
return 1;
}
print <<EOT;
HTTP/1.0 401 Access Denied
WWW-Authenticate: NTLM
WWW-Authenticate: Basic realm="$ip"
Content-Length: 24
Content-Type: text/html
EOT
print "Error: Access is Denied.";
exit;
}
--
Totten, William David (Bill) Computer and Information Science Major
totten @ pobox . com University of Delaware (Newark, DE; USA)
http://pobox.com/~totten/ Friends don't let friends use emacs
------------------------------
Date: 1 Jul 1997 09:54:38 GMT
From: Martin Patzel <patzel@happy.informatik.uni-ulm.de>
Subject: Forking process doesn't recognize EOF
Message-Id: <5pak4u$ajq$1@happy.informatik.uni-ulm.de>
Hi,
the program below creates a sub-process which works as an input filter
to the main perl program. All data transfer should be through stdin/stdout.
So the data pipe should look like this:
stdin -> perl-sub-process ----(pipe)----> perl-main-process -> stdout
The only problem now I have is: The perl main-process (father) doesn't
notice the EOF of it's stdin (which comes from the sub-process).
The sub-process dies, the father gets a SIGCHLD and does a wait, but
it doesn't recognize the EOF.
In the end the main process should also exec another (real) program,
but if I uncomment the exec-line below, the (real) program doesn't
recognize the EOF, too.
Another mysterious thing: if I uncomment the "close STDIN" in the
parent process, no data at all is copied to the file t1.log.
Where is the problem? Could someone help me please?
Thanks,
Martin
#!/usr/bin/perl
pipe P_RD, P_WR;
$SIG{CHLD} = sub { $child = wait; print "sigchld: $child\n"};
if ($pid = fork) # Parent reads from pipe (=stdin) and writes to stdout
{
# close STDIN;
open(STDIN, "<&P_RD");
close P_RD;
open (T, ">t1.log") && do { while(<>) {print T}; close T};
# use the line above *or* below
# exec("cat -u >t1.log");
exit 1;
}
else # Child reads from stdin and writes to pipe (=stdout)
{
open(STDOUT, ">&P_WR");
close P_WR;
select(STDOUT); $| = 1;
exec("cat -u");
exit 1;
}
--
Martin Patzel, Universitaet Ulm, URG Informatik, 89069 Ulm, Germany
patzel@informatik.uni-ulm.de
------------------------------
Date: Tue, 01 Jul 1997 12:51:38 +0200
From: Ivar Hxsteng <ivar.hosteng@merkantildata.com>
Subject: hashes of hashes in perl5
Message-Id: <33B8E13A.41C67EA6@merkantildata.com>
I am trying to access the second level hashes in a hash of hashes like
this:
#!/usr/bin/perl -w
$$hh{"foo"}{"test1"}="some data";
$$hh{"foo"}{"test2"}="some other data";
$$hh{"bar"}{"tst1"}="some data2";
$$hh{"bar"}{"tst2"}="some other data2";
foreach $i (sort keys %$hh) {
print "Starting dataset $i:\n";
foreach $j (sort keys %$hh{$i}) {
print "Data for $j is $$hh{$i}{$j}\n";
}
}
Is there anyone that can tell me how to do this?
--
Regards,
Ivar E. Hxsteng
email: ivar.hosteng@merkantildata.no
------------------------------
Date: Tue, 01 Jul 1997 12:42:11 +0100
From: Simon Fairey <sfairey@adc.metrica.co.uk>
To: "Ivar Hxsteng" <ivar.hosteng@merkantildata.com>
Subject: Re: hashes of hashes in perl5
Message-Id: <33B8ED13.1CFB@adc.metrica.co.uk>
Ivar Hxsteng wrote:
>
> I am trying to access the second level hashes in a hash of hashes like
> this:
>
> #!/usr/bin/perl -w
>
> $$hh{"foo"}{"test1"}="some data";
> $$hh{"foo"}{"test2"}="some other data";
> $$hh{"bar"}{"tst1"}="some data2";
> $$hh{"bar"}{"tst2"}="some other data2";
>
> foreach $i (sort keys %$hh) {
> print "Starting dataset $i:\n";
> foreach $j (sort keys %$hh{$i}) {
> print "Data for $j is $$hh{$i}{$j}\n";
> }
> }
>
> Is there anyone that can tell me how to do this?
>
> --
> Regards,
> Ivar E. Hxsteng
> email: ivar.hosteng@merkantildata.no
See the 'perldsc' man page for all your needs.
Simon
------------------------------
Date: Tue, 1 Jul 1997 15:14:48 -0400
From: Akshat Hasmukh Shah <ahs+@andrew.cmu.edu>
Subject: help with libwww
Message-Id: <kniJQcy00WB_0bqkk0@andrew.cmu.edu>
Hi guys,
I am fairly new to programming in perl and someone pointed me
towards this newsgroup. I am trying to install the libwww library. TO
install this library I need IO::Socket. so I got the IO library and
installed it to a local directory
(/nfs/al3/record/temp/PA-RISC1.1/5.003/lib/perl5). Then I
did a
setenv PERL5LIB /nfs/al3/record/temp/PA-RISC1.1/5.003/lib/perl5
then I went back to compile the libwww. Unfortunately whenever I do a
perl5 Makefile.PL I am getting this error
Checking for IO::Socket. failed
Can't find loadable object for module IO in @INC
(/nfs/al3/record/temp/PA-RISC1.1/5.003/lib/perl5
/usr/local/lib/perl5/PA-RISC1.1/5.003 /usr/local/lib/perl5
/usr/local/lib/perl5/site_perl/PA-RISC1.1
/usr/local/lib/perl5/site_perl .) at
/nfs/al3/record/temp/PA-RISC1.1/5.003/lib/perl5/IO/Handle.pm line 229
BEGIN failed--compilation aborted at
/nfs/al3/record/temp/PA-RISC1.1/5.003/lib/perl5/IO/Socket.pm line 112.
I don't understand this error since there is a file called Socket.pm
in my /nfs/al3/record/temp/PA-RISC1.1/5.003/lib/perl5 directory.
I am pretty sure i am probably missing something very trivial here. So
if someone could email me an answer ASAP would much appreciate it. It is
hard for me to read the newsgroup (news server problems). Thanks..
ak
------------------------------
Date: Tue, 01 Jul 1997 13:57:27 +0100
From: Alastair R Todd <alastair@net7.co.uk>
To: Conrad Damon <damon@netserver.stanford.edu>
Subject: Re: How can I debug a CGI script?
Message-Id: <33B8FEB7.7972@net7.co.uk>
You could test from the command line. Perl installations generally get a
'Path', so from dos, or shell type perl <filename> and use 'print'
statements for your tracing.
Conrad Damon wrote:
>
> "Premature End of Script Headers" means the script didn't produce a...
>
> --------
>
> The Halls wrote:
> >
> > Hi,
> >
> > I'm using a complicated CGI script written by someone else in Perl on my
> > web site. Every once in a while, it crashes, and all that shows up in
> > the error log is a Premature End of Script Headers error. I don't know
> > Perl very well, so this may be a stupid question, but how can I debug
> > the script and figure out were in the program it is crashing?. I've done
> > some C++ CGI programming and have seen that the Premature End of Script
> > Headers error can occur on a lot of errors, such as infinite loops, but
> > I'm not sure where to look in this Perl program. Does anyone know how I
> > can figure out where the error is occurring? Please cc to e-mail. Thanks
> > a lot.
> >
> > Nick
--
System's Development Manager
http://www.net7.co.uk
------------------------------
Date: Tue, 01 Jul 1997 10:47:51 +0100
From: Simon Fairey <sfairey@adc.metrica.co.uk>
To: Woodrow Hill <whill@mindspring.com>
Subject: Re: Looking for text indexing scripts/modules
Message-Id: <33B8D246.2781@adc.metrica.co.uk>
Woodrow Hill wrote:
>
> Greetings!
>
> I'm a fairly new Perl programmer, and I have been given a
> project to search through a set of archives from a mailing list, and
> generate a index of the files. The basic idea is to keep the actual
> files gzipped, and to search the index and then pop out the appropiate
> file when necessary.
> Well, actually, she wants to generate the article from the
> index itself, if that might save space...anyway, does anyone know of a
> place to go and find what I seek? I have the man pages, The Camel
> book, and have looked in the CPAN archives as well as a couple of
> other on-line archives, to no avail. (Would using DBM be an option
> here? The archives are about 200-300 k each f a weeks worth of
> compressed articles.)
> Anyone who help will be noted and logged in the web site for
> this archive!
>
> ----Woodrow Hill
I actually did something very similar to this, essentially I had a
script which would preprocess the digest extracting all the subject
information and creating 2 files. One was an index of all the subjects
while the other was the articles themselves with a crossreference to the
index file. I did it this way primarily to speed up the processesing as
one of the digest files was in excess of 50M when uncompressed and I
needed a way to find articles quickly. I wraped a Perl/Tk script around
the whole thing which gives two search options, search subjects or
search article contents and then gives the user a list of matching
articles which can be viewed. It sound like with some modification this
might suit your needs, if you want a hand let me know.
Simon
------------------------------
Date: Tue, 01 Jul 1997 10:51:38 GMT
From: scott@2tp.com (Scott Thomason)
Subject: Net::NNTP missing newsgroups?
Message-Id: <33b8df53.1631430@news.execpc.com>
Argh! I'm trying to write a simple news filter, and as a first step I
tried to use Net::NNTP to simply list all the groups I was interested
in. Using the following script to connect to news.execpc.com for
groups alt.humor.*, I get the following results. Unfortunately, the
list is incomplete; only about half the newsgroups show up. There are
13 newsgroups, all with current articles, and I only return 6 of them.
I'll be damned if I can figure out the bug in my script...anyone have
an idea? Thanks in advance for looking...here's the script...
#!/usr/bin/perl
use Net::NNTP;
local($p_nh, $p_ng) = @ARGV;
print "Using news host $p_nh, news group(s) $p_ng.\n";
$nh = Net::NNTP->new($p_nh);
if (!$nh) {
die "$p_nh wasn't a valid newshost!"
}
$ng = $nh->newsgroups("$p_ng");
newsgroups:
foreach $newsgroup (keys %$ng) {
# $nh->group($newsgroup);
print "***\nNew group: $newsgroup\n";
}
$nh->quit;
...and here's the results...
C:\temp>perl listnews.pl news.execpc.com alt.humor.*
Using news host news.execpc.com, news group(s) alt.humor.*.
***
New group: alt.humor.best-of-usenet
***
New group: alt.humor.jewish
***
New group: alt.humor.seeking-abuse
***
New group: alt.humor.best-of-usenet.d
***
New group: alt.humor.net-abuse
***
New group: alt.humor.parodies
C:\temp>
------------------------------
Date: Tue, 01 Jul 1997 10:43:52 +0100
From: Alastair R Todd <alastair@net7.co.uk>
Subject: Perl CGI scripts getting slower...and...slower..
Message-Id: <33B8D158.D56@net7.co.uk>
We have Netscape Enterprise Server 2.0 running on a Challenge-S SGI box
and until recently our CGI scripts were running fine. However recently
the scripts really, I mean really, slowed down - all of them. We use a
generic Perl mailer written by Reuven M. Lerner - Perl-Mail, which uses
Sendmail to redirect the input.
Has anyone experienced similar difficulties, and or could suggest a
better Perl mailer and/or a better Unix mail prog.
One alternative is to set up Enterprise on an NT box and redirect cgi
there, but again I have no knowledge as to the best software.
Sincerely,
--
System's Development Manager
http://www.net7.co.uk
------------------------------
Date: 1 Jul 1997 05:19:47 -0700
From: jcr@idiom.com (John C. Randolph)
Subject: Re: Perl: deleting spaces etc in strings
Message-Id: <5pasl3$kb7@idiom.com>
I'm going to beat this drum again. This, too, is a job for tr///.
To eliminate spaces, try:
tr/\s//;
-jcr
X <eeiX@eei.ericsson.se> writes:
>I'm new to this language and I was wondering could anyone tell me how to
>delete spaces from strings such as:
> 152 41-CAX 102 577
------------------------------
Date: Tue, 01 Jul 1997 12:36:13 +0100
From: Simon Fairey <sfairey@adc.metrica.co.uk>
To: Shaun O'Shea <lmisosa@eei.ericsson.se>
Subject: Re: Perl: How to delete spaces from an value/element in an assoc array
Message-Id: <33B8EBAC.59E2@adc.metrica.co.uk>
Shaun O'Shea wrote:
>
> I want to remove the spaces from something similar to the following:
>
> 152 41-cax 102 577
>
> Someone else suggested:
> $string= s/\s//g;
> But this seemed to remove all characters!
> --
> ********************************************************************************
> ********************************************************************************
>
> Shaun O'Shea
> lmisosa@eei.ericsson.se
> shaunos@orca.ucd.ie
>
> ********************************************************************************
> ********************************************************************************
You have made a slight syntactical error it should be:
$string =~ s/\s//g;
^ This is what you are missing.
Simon
------------------------------
Date: Tue, 01 Jul 1997 11:52:20 +0100
From: Simon Fairey <sfairey@adc.metrica.co.uk>
To: o-su ken'ichi <t95129ku@sfc.keio.ac.jp>
Subject: Re: TimeSorting
Message-Id: <33B8E164.15FB@adc.metrica.co.uk>
o-su ken'ichi wrote:
>
> Hello, I hope you are fine.;-)
> I'm thinking over how can I sort the time.
> Like :
>
> $inputTime="97/06/30/13:25:10"; # year/month/day/hour:minute:second
>
> @time=(97/06/28/13:25:10, 97/06/29/13:25:10, 97/06/30/13:25:10,
> 97/07/01/13:25:10, 97/07/01/14:25:10);
>
> foreach(@time){
> ####time sorting algorithm
> if($_ <= $inputTime){
> print $_;
> }
> }
>
> This means I have to translate
> the time parameter(year/month/day/hour:minute:second) into simple integer,
> and sort the rusult.
> HOW DO I TRANSLATE TIME INTO INTEGER NUMBER?
>
> Thank you very much in advance!
>
> From Tokyo,
> Ken'ichi Unnai
> t95129ku@sfc.keio.ac.jp
Look at the Time modules for perl at your local CPAN, you should find
what you need; I think Time::JulianDay should do what you want )
Simon
------------------------------
Date: Tue, 1 Jul 1997 11:53:50 GMT
From: ddurand@hpplus17.cern.ch (Jean-Damien Durand)
To: t95129ku@sfc.keio.ac.jp (o-su ken'ichi )
Subject: Re: TimeSorting
Message-Id: <ECn2Dr.G4v@news.cern.ch>
> $inputTime="97/06/30/13:25:10"; # year/month/day/hour:minute:second
>
> @time=(97/06/28/13:25:10, 97/06/29/13:25:10, 97/06/30/13:25:10,
> 97/07/01/13:25:10, 97/07/01/14:25:10);
> foreach(@time){
> ####time sorting algorithm
> if($_ <= $inputTime){
> print $_;
> }
> }
> This means I have to translate
> the time parameter(year/month/day/hour:minute:second) into simple integer,
> and sort the rusult.
> HOW DO I TRANSLATE TIME INTO INTEGER NUMBER?
The year/month/day/hour:minute:second is not a standard format as far as I
know ! Neverthless the Date module and its str2time function is for you. Here I
had to translate a little your format to one of the multiple standard ones...
#!/usr/local/bin/perl
use HTTP::Date;
@time=('97/06/28/13:25:10','97/06/29/13:25:10','97/06/30/13:25:10',
'97/07/01/13:25:10','97/07/01/14:25:10');
$inputTime = '97/07/01/00:00:00' ;
# What is this (assumed) log-file format ????
# GLobal translation to ISO 8601 (without zone), with
# no optimization. Do them yourself.
$inputTime2 = $inputTime ;
$inputTime2 =~ s/(\d*)\/(\d*)\/(\d*)\/(.*)/19$1-$2-$3 $4/ ;
foreach @time){
$time2 = $_ ;
$time2 =~ s/(\d*)\/(\d*)\/(\d*)\/(.*)/19$1-$2-$3 $4/ ;
if(str2time($time2) <= str2time($inputTime2)){
print "$_\n" ;
}
}
Cheers, Jean-Damien.
--
*******************************************************
* Jean-Damien Durand (Jean-Damien.Durand@cern.ch) *
* www : http://wwwcn.cern.ch/~ddurand/ *
*******************************************************
------------------------------
Date: Tue, 01 Jul 1997 16:01:29 -0600
From: tim@hcirisc.cs.binghamton.edu
Subject: When was PERL created?
Message-Id: <867790152.23274@dejanews.com>
Does anyone have info on when PERL was created? Some idiot wrote a
proposal to my company saying that PERL has no practical application
outside of the WWW. So I wanted to know by how much PERL pre-dates
the web for a little extra oomph for my reply. Thanks.
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: 1 Jul 1997 11:50:12 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Y2K and Perl (was Re: Y2K problems??)
Message-Id: <5paqtk$7ma@lyra.csx.cam.ac.uk>
Russ Allbery <rra@stanford.edu> wrote:
> /bin/date *does* have Y2K problems on some platforms. For
>example, on SunOS /bin/date has no way of returning the full year rather
>than just the last two digits.
That's funny. On my SunOS box:
% /bin/date
Tue Jul 1 12:47:07 BST 1997
% uname -a
SunOS nmg1.csi. 4.1.3 2 sun4c
So is my SunOS different from everyone else's?
Mike Guy
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.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 690
*************************************