[18419] in Perl-Users-Digest
Perl-Users Digest, Issue: 587 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 29 18:06:50 2001
Date: Thu, 29 Mar 2001 15:05:50 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <985907150-v10-i587@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 29 Mar 2001 Volume: 10 Number: 587
Today's topics:
$title and ($title) as lvalue <maheshasolkar@yahoo.com>
Re: [Swig] installation problem with SWIG 1.1p5 <zhuzm@hpsgns1.sgp.hp.com>
Re: add lines from logfile (Jon Bell)
Re: add lines from logfile (Logan Shaw)
Re: add lines from logfile <yanoff@yahoo.com>
Re: Adding Values from an Array 3 <m0rejunkmail@home.com.nospam>
Adding Values from an Array <m0rejunkmail@home.com>
Re: Adding Values from an Array <m0rejunkmail@home.com.nospam>
Re: broken pipe error on server (David Efflandt)
Can we make the @array->push(1..10) syntax <johnlin@chttl.com.tw>
Re: Can we make the @array->push(1..10) syntax nobull@mail.com
Re: Can we make the @array->push(1..10) syntax (Logan Shaw)
Re: Can we make the @array->push(1..10) syntax <johnlin@chttl.com.tw>
Re: Can we make the @array->push(1..10) syntax <andrew@erlenstar.demon.co.uk>
cannot fork? <jackkon@pchome.com.tw>
Re: cannot fork? (Gwyn Judd)
Re: cannot fork? (Randal L. Schwartz)
cgi/perl sendmail problem <davinci@gmx.at>
Re: cgi/perl sendmail problem (Abigail)
changing time/date <Waarddebon@chello.nl>
Re: changing time/date <peter.s@tjgroup.dk>
Re: changing time/date <peter.s@tjgroup.dk>
Re: changing time/date (Garry Williams)
Re: check prototype error <webmaster@webdragon.unmunge.net>
Re: check prototype error (Garry Williams)
Re: date handling? (The Mosquito ScriptKiddiot)
Deleting a line from a Flat Text File <peter@venturenet.co.za>
Re: Deleting a line from a Flat Text File (Bernard El-Hagin)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 29 Mar 2001 14:23:45 -0800
From: "Mahesh A" <maheshasolkar@yahoo.com>
Subject: $title and ($title) as lvalue
Message-Id: <tc7degfaii9qfb@corp.supernews.com>
Hi,
Can anyone elaborate on the difference between...
open (NOTE, $notesFile) || die "Cannot open $notesFile to read\n";
my $title = <NOTE>;
and
open (NOTE, $notesFile) || die "Cannot open $notesFile to read\n";
my ($title) = <NOTE>;
The second assignment ate up the whole NOTE handler, as if the
INPUT_RECORD_SEPARATOR was undef'd. But only the first line came into
$title.
Thanks,
-M
------------------------------
Date: Thu, 29 Mar 2001 16:25:43 +0800
From: Zhu Zheng Ming <zhuzm@hpsgns1.sgp.hp.com>
To: David Beazley <beazley@cs.uchicago.edu>, swig@cs.uchicago.edu
Subject: Re: [Swig] installation problem with SWIG 1.1p5
Message-Id: <3AC2F187.F3A207DD@hpsgns1.sgp.hp.com>
Hi Dave,
One question, if I want to call C++ method from perl script, is
Swig the best way to do so?
I read the "XS reference manual", there is a session "Using XS
with C++", but seems it doesn't work (don't recognize class).
so I searched the web and found many people recommend SWIG. and
also I found in "Advanced Perl Programming" session "XS features",
the first paragraph, says: XS can not support for struct or class.
I have an doubt, if XS can not support for struct or class, that
means XS can not support C++, am I right? why they put that
session in the document?
if SWIG is the only way to integrates Perl,...with programs written
in C++, I will try to resolve the compile error I met below, and
continue going with SWIG, otherwise, I have to find other solutions.
Regards,
Zheng Ming
David Beazley wrote:
>
> Zhu Zheng Ming writes:
> > Hi Dave,
> >
> > I did what you told me, download from www.swig.org,
> > --SWIG 1.1p5 is the latest stable release (2/5/98).
> > but the result is same.
> >
> > $ export CXX=aCC
> > $./configure --with-lang=PERL5
> > $make
> > $make install
> > $make testbuild
> >
> > Do I need to modify 'Makefile.template' manually?
> > though I have no idea what I should change. :-)
> >
>
> You might have to edit it. I have no idea what you would change--I
> don't have any HPUX machines.... perhaps it's just a matter of
> changing some pathnames.
>
> -- Dave
> > > Hi,
> > > I downloaded swig1.1p5 from swig.org, and try to install it
> > > on HPUX. my C++ compiler is aCC. what I did:
> > >
> > > $export CC=aCC
> > > $./configure --with-lang=PERL5
> > > $make
> > > $make install
> > > $make testbuild
> > >
> > > all the build were FAILED. since I want to use perl5_static (C++)
> > > so I checked the perl5_static.c++.output, the error info as:
> > >
> > > ----------------------------------------------------------------------------------
> > > make -f ../../Makefile.template SRCS='' SWIG='../../swig' \
> > > SWIGOPT='-DSTATIC -DPERL5 -I../../swig_lib' \
> > > TARGET='shapes' INTERFACE='shapes.i ' perl5_static_cpp
> > > ../../swig -perl5 -c++ -static -lperlmain.i -DSTATIC -DPERL5
> > > -I../../swig_lib shapes.i
> > > Generating wrappers for Perl 5
> > > aCC -Dexplicit= shapes_wrap.c
> > >-I/opt/perl5/lib/5.6.0/PA-RISC1.1/CORE -L/
> > > opt/perl5/lib/5.6.0/PA-RISC1.1/CORE -lperl -lnsl -ldld -lm -o shapes
> > > Error 172: "shapes_wrap.c", line 292 # Undeclared variable 'sv_undef'.
> > > } else if (sv == &sv_undef) { /* Check for undef */
> > > ^^^^^^^^
> > > Error 172: "shapes_wrap.c", line 462 # Undeclared variable 'do_undump'.
> > > if (!do_undump) {
> > > ^^^^^^^^^
> > > Error 172: "shapes_wrap.c", line 799 # Undeclared variable 'sv_yes'.
> > > ST(0) = &sv_yes;
> > > ^^^^^^
> > > *** Error exit code 2
> > >
> > > Stop.
> > > *** Error exit code 1
> > >
> > > Stop.
> > >
> > > -----------------------------------------------------------------------------------
> > >
> > > I checked TROUBLESHOOTING, it just mentioned a compile option
> > > "-Dexplict=",
> > > but it's already there.
> > >
> > > and also I checked perl include file, sv_yes & sv_undef is defined
> > > in embedvar.h, and I found in perl.h, lines related with embedvar.h
> > > were commented out. like this:
> > >
> > > #ifdef PERL_FOR_X2P
> > > /*
> > > * This file is being used for x2p stuff.
> > > * Above symbol is defined via -D in 'x2p/Makefile.SH'
> > > * Decouple x2p stuff from some of perls more extreme eccentricities.
> > > */
> > > #undef MULTIPLICITY
> > > #undef USE_STDIO
> > > #define USE_STDIO
> > > #endif /* PERL_FOR_X2P */
> > > .
> > > .
> > > .
> > > /* The following must follow proto.h as #defines mess up syntax */
> > > #if !defined(PERL_FOR_X2P)
> > > # include "embedvar.h" <-------here
> > > #endif
> > >
> > > Is that means I have to do some changes with Perl configuration?
> > >
> > > Regards,
> > > Zheng Ming
------------------------------
Date: Thu, 29 Mar 2001 19:18:53 GMT
From: jtbell@presby.edu (Jon Bell)
Subject: Re: add lines from logfile
Message-Id: <GAz4BI.KwM@presby.edu>
In article <3AC34034.DB1D4AD2@chemsoft.de>,
Tobias Dresbach <td@chemsoft.de> wrote:
>Hi all,
>i have a log file like the following:
>IP-Address Port kbytes
>192.168.0.1 53 10
>192.168.1.2 21 150
>how is it possible to add all kbytes from the same port and ip-address?
Assuming you want to generate a table of total # of bytes from each port +
IP address combination, I'd do it something like this:
Read each line of the file and process as follows:
Split it into IP, port, and # of bytes
Concatenate IP and port together, e.g. "192.168.0.1:53"
Use the IP:port combination as the key to a hash, and add the
# of bytes to the corresponding value.
(end of file reading loop)
For each key in the hash
print the IP:port and the # of bytes
--
Jon Bell <jtbell@presby.edu> Presbyterian College
Dept. of Physics and Computer Science Clinton, South Carolina USA
------------------------------
Date: 29 Mar 2001 15:20:01 -0600
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: add lines from logfile
Message-Id: <9a08u1$oan$1@boomer.cs.utexas.edu>
In article <3AC34034.DB1D4AD2@chemsoft.de>,
Tobias Dresbach <td@chemsoft.de> wrote:
>IP-Address Port kbytes
>192.168.0.1 53 10
>192.168.1.2 21 150
>how is it possible to add all kbytes from the same port and ip-address?
Here you go:
my ($ip, $port, $kB);
while (<>)
{
($ip, $port, $kB) = split;
$totals{$ip}{$port} += $kB;
}
Printing them out is left as an exercise.
- Logan
--
whose? my your his her our their _its_
who's? I'm you're he's she's we're they're _it's_
------------------------------
Date: Thu, 29 Mar 2001 16:21:59 -0600
From: Scott Yanoff <yanoff@yahoo.com>
To: Tobias Dresbach <td@chemsoft.de>
Subject: Re: add lines from logfile
Message-Id: <3AC3B587.FE585E3D@yahoo.com>
Tobias Dresbach wrote:
>
> Hi all,
> i have a log file like the following:
> IP-Address Port kbytes
> 192.168.0.1 53 10
> 192.168.1.2 21 150
> how is it possible to add all kbytes from the same port and ip-address?
You can just read in the file and make a unique array/hash element for
each IP address/port pair. Here is my attempt at this, from memory.
Good luck.....
#!/usr/bin/perl -w
use strict;
my %list = ();
# Read from standard in a space-separated list of data and store to a
hash:
while (<STDIN>) {
my ($ip_address, $port, $kb) = split(/\s*/);
my $unique = $ip_address.",".$port;
$list{$unique} += $kb;
} ## while
# For every element in the hash, print it out:
print "IP Address,Port:\tKB:\n";
foreach (sort keys %list) { print "$_\t$list{$_}\n; }
exit 0;
--
Scott Yanoff
yanoff@yahoo.com
http://www.yanoff.org
------------------------------
Date: Thu, 29 Mar 2001 22:35:55 GMT
From: FORM Rookie <m0rejunkmail@home.com.nospam>
Subject: Re: Adding Values from an Array 3
Message-Id: <3AC3BE51.C0E489EB@home.com.nospam>
>
Also....
If there was nothing in $thing1, then it should recognize it as a no
entry but will still be added to $thing2 and come up with the $total.
~FORM Rookie
>
------------------------------
Date: Thu, 29 Mar 2001 22:30:26 GMT
From: FORM Rookie <m0rejunkmail@home.com>
Subject: Adding Values from an Array
Message-Id: <3AC3BD08.8C7CD36@home.com.nospam>
OK here we go again. I need your help.
Here's what I have:
%some_things = ($thing1 => "2",
$thing2 => "4");
foreach $object (keys %some_things) {
print "$object is roughly $some_things{$object}";
}
------------------------------------------------------
Here's where I hit the infamous "brick wall".
I need to add the values of $thing1 (2) and $thing2 (4) for a Grand
Total.
$total = ((value of $thing1) + (value of $thing1));
I tried different approaches and hit a brick wall. Any help is
appreciated.
~FORM Rookie
------------------------------
Date: Thu, 29 Mar 2001 22:32:34 GMT
From: FORM Rookie <m0rejunkmail@home.com.nospam>
Subject: Re: Adding Values from an Array
Message-Id: <3AC3BD88.CF246C@home.com.nospam>
FORM Rookie wrote:
> OK here we go again. I need your help.
>
> Here's what I have:
>
> %some_things = ($thing1 => "2",
> $thing2 => "4");
>
> foreach $object (keys %some_things) {
>
> print "$object is roughly $some_things{$object}";
>
> }
>
> ------------------------------------------------------
>
> Here's where I hit the infamous "brick wall".
>
> I need to add the values of $thing1 (2) and $thing2 (4) for a Grand
> Total.
>
> $total = ((value of $thing1) + (value of $thing1));
>
> I tried different approaches and hit a brick wall. Any help is
> appreciated.
>
> ~FORM Rookie
Also, if $thing1 was missing, it will just a nothing to $thing2.
Thanks.
~FORM Rookie
------------------------------
Date: Thu, 29 Mar 2001 02:04:21 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: broken pipe error on server
Message-Id: <slrn9c5614.1k7.efflandt@efflandt.xnet.com>
On Wed, 28 Mar 2001, Marcus Linorit <markus.pinkert@ens-office.de> wrote:
>Hi,
>Do you know these complete perl scripts, which some HTML-editors offer to
>put them into your webpresentation. There is such a script called
>mailmanager.pl. It has worked for a long time but now it only works in 1 of
>ca. 15 cases. In the other cases it gives back an "Broken Pipe" -error. I
>have testet it on the server, an Unix-system, where this error is shown. At
>my computer, an Windows98 system, the Compiler didn't show any errors.
>Take a look at the script, what do you think. Has anyone of you ever seen
>such error, or is there some knowlege how to get this error away?
>Maybe the server has Problems with this line:
# insert this here:
print "$mail_prog kaput\n" unless -x $mail_prog;
> open (MAIL, "|$mail_prog $Mail") || print "Fehler beim Zugriff auf
>$mail_prog!\n";
Also the open() error should include the variable $! that tells why it
cannot open. I don't know what $mail_prog you define for Win98? But for
Unix or Linux systems I have mailpath.cgi that tries to find an executable
sendmail in various paths (see virtualave site in my sig).
>But how can I fix the bug, because without this line, there are much more
>other errors and the script dosn't work anymore.
>Greetings, Marcus.
--
David Efflandt efflandt@xnet.com http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
------------------------------
Date: Thu, 29 Mar 2001 10:23:55 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: Can we make the @array->push(1..10) syntax
Message-Id: <99u6g4$6v1@netnews.hinet.net>
Dear all,
Seeing this in another thread ("Better way to Flushing STDOUT?")
use IO::Handle;
STDOUT->flush; # normally is flush(STDOUT)
I said "Wow, OO like syntax. Great!!! Then, can we do this?"
use Array;
@array->push(1..10);
Note: I am not saying $arrayref->push(1..10);
Although it is not so useful, it's a way of learning Perl.
I tried many ways (protocol, overload...). It seems not to be do-able.
Any ideas? Thank you.
John Lin
P.S. Of course, we can also try %hash->keys and %hash->values.
------------------------------
Date: 29 Mar 2001 08:35:57 +0100
From: nobull@mail.com
Subject: Re: Can we make the @array->push(1..10) syntax
Message-Id: <u9r8zh3r0g.fsf@wcl-l.bham.ac.uk>
"John Lin" <johnlin@chttl.com.tw> writes:
> I said "Wow, OO like syntax. Great!!! Then, can we do this?"
>
> use Array;
> @array->push(1..10);
Not at present. It would probably be possible in Perl 6. Note that
there was another proposal here about two weeks ago that proposed
different semantics for that same syntax. Of course you can have
both! All you need is to include a different module.
In some contexts in Perl5 the -> operator already causes an array or
hash on it's left to be DWIMed in to a reference to the same.
@array->[0]; # Interpreted as (\@array)->[0];
I have, up until now, been firmly in the camp that says this is a bug.
However if it was _always_ the case I wouldn't have a problem with it.
I hereby officially change my stance on this issue to 'fence sitter'.
> Note: I am not saying $arrayref->push(1..10);
ISTR this one is already in one of the Perl6 RFCs - can't recall it's
status though
One final point. I often use syntactic sugar to make push() more
palatible:
push @array, 1 .. 10; # 'Raw' syntax
push @array => ( 1 .. 10 ); # The same with 'sugared' syntax
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 29 Mar 2001 03:04:57 -0600
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Can we make the @array->push(1..10) syntax
Message-Id: <99utrp$k33$1@boomer.cs.utexas.edu>
In article <99up15$gv1@netnews.hinet.net>,
John Lin <johnlin@chttl.com.tw> wrote:
>"Logan Shaw" wrote
>> John Lin wrote:
>> >I said "Wow, OO like syntax. Great!!! Then, can we do this?"
>> >use Array;
>> >@array->push(1..10);
>>
>> That's because in Perl there aren't really any objects. Instead, there
>> are blessed references.
>
>Really? Please look at this:
>
>perl -e "STDOUT->flush"
>Can't locate object method "flush" via package "IO::Handle" at -e line 1.
>
>perl -MIO::Handle -e "STDOUT->flush"
>It is OK.
>
>STDOUT is not a reference, right? But it seems to be implicitly blessed
>into IO::Handle. (A Perl internal data structure is dependent with
>an external module? That's weird.)
I must admit, you're rapidly nearing the limits of my knowledge of
this area of Perl. But I will proceed with what I think is the
right explanation.
The "->" syntax can be applied to one of two things:
1. A reference.
2. A package (i.e. class) name.
I had already mentioned references, but I had not mentioned package
names. What happens when you use a package name on the left side of a
"->" operator is that you pass the package name as the first argument
to the method named by what's on the right side of the "->". So, when
you do this:
SomePackage->new(1,2,3);
You're actually calling SomePackage::new with the argument list
("SomePackage", 1, 2, 3); I believe it would be equivalent to doing
this instead:
SomePackage::new("SomePackage", 1, 2, 3);
Do "perldoc perlop" and "perldoc perlobj" for a little more info on that.
So, getting back to the IO::Handle question, I guess what happens is
that when IO::Handle loads, it does some magic to add STDIN, STDOUT,
and STDERR to the list of packages. In fact, it may use some kind of
trick, like changing the symbol table so that STDIN et al are aliases
for IO::Handle.
Actually, I just tracked it down, and apparently (part of?) what
happens is that FileHandle.pm does this:
# Rebless standard file handles
bless *STDIN{IO}, "FileHandle" if ref *STDIN{IO} eq "IO::Handle";
bless *STDOUT{IO}, "FileHandle" if ref *STDOUT{IO} eq "IO::Handle";
bless *STDERR{IO}, "FileHandle" if ref *STDERR{IO} eq "IO::Handle";
I'm not quite sure what this is doing, to be honest. (I've always
avoided learning about the "*" symbol table operator, since I figured
it would prevent me from being tempted to ever use it.) Now that I
think about it, it doesn't seem like it's adding them to the list of
packages. Instead, it seems like it's somehow making them into
references, even though they're not scalar variables. That's probably
cleaner anyway.
>> >Note: I am not saying $arrayref->push(1..10);
>
>> If you want, you can define a class that happens to work alot like an array:
>> package Array;
>> [snip]
>
>Hmm... That's $arrayref->push(1..10); syntax. I am not talking about this.
Oh. I didn't think that your goal was anything to do with the syntax.
I thought you were trying to understand how you could have an array
that acts like an object. Right now, you can have an array *of* things
that act like an object, but the array itself can't do that.
>My point is: STDOUT is not a reference, yet it can have STOUT->flush syntax.
>P.S. Proof that STDOUT is not a reference:
>
>use strict;
>print ref(*STDOUT); # Can't use print ref(STDOUT) in 'use strict'
>
>gets nothing. (I imagined it would print "IO::Handle")
Well, indeed this *does* print "IO::Handle":
use strict
print ref(*STDOUT{IO});
Precisely why, I don't know. In fact, the "{IO}" part of the syntax
really confuses me...
- Logan
--
whose? my your his her our their _its_
who's? I'm you're he's she's we're they're _it's_
------------------------------
Date: Thu, 29 Mar 2001 15:43:40 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: Re: Can we make the @array->push(1..10) syntax
Message-Id: <99up15$gv1@netnews.hinet.net>
"Logan Shaw" wrote
> John Lin wrote:
> >I said "Wow, OO like syntax. Great!!! Then, can we do this?"
> >use Array;
> >@array->push(1..10);
>
> That's because in Perl there aren't really any objects. Instead, there
> are blessed references.
Really? Please look at this:
perl -e "STDOUT->flush"
Can't locate object method "flush" via package "IO::Handle" at -e line 1.
perl -MIO::Handle -e "STDOUT->flush"
It is OK.
STDOUT is not a reference, right? But it seems to be implicitly blessed
into IO::Handle. (A Perl internal data structure is dependent with
an external module? That's weird.)
> >Note: I am not saying $arrayref->push(1..10);
> If you want, you can define a class that happens to work alot like an array:
> package Array;
> [snip]
Hmm... That's $arrayref->push(1..10); syntax. I am not talking about this.
> But arrays and hashes aren't references.
My point is: STDOUT is not a reference, yet it can have STOUT->flush syntax.
Arrays and hashes aren't references, possibly they could also have @array->push
or %hash->keys syntax, but I don't know how to work it out.
Any ideas? Thank you.
John Lin
P.S. Proof that STDOUT is not a reference:
use strict;
print ref(*STDOUT); # Can't use print ref(STDOUT) in 'use strict'
gets nothing. (I imagined it would print "IO::Handle")
P.P.S. An autovivificated handle IS a reference.
It's blessed into "GLOB", but when method is evoked,
Perl looks in package "IO::Handle". Weird.
use strict;
my $f;
open $f,">>out" or die $!;
print ref $f;
$f->flush;
__END__
GLOB
Can't locate object method "flush" via package "IO::Handle" at line 5.
------------------------------
Date: 29 Mar 2001 12:32:55 +0100
From: Andrew Gierth <andrew@erlenstar.demon.co.uk>
Subject: Re: Can we make the @array->push(1..10) syntax
Message-Id: <87g0fwzu6w.fsf@erlenstar.demon.co.uk>
>>>>> "Logan" == Logan Shaw <logan@cs.utexas.edu> writes:
Logan> So, getting back to the IO::Handle question, I guess what
Logan> happens is that when IO::Handle loads, it does some magic to
Logan> add STDIN, STDOUT, and STDERR to the list of packages. In
Logan> fact, it may use some kind of trick, like changing the symbol
Logan> table so that STDIN et al are aliases for IO::Handle.
no, that's not what it does.
What actually happens is this (at least in 5.005_03); the method call
operator, when called with a string as the lefthand parameter, looks
up that string in the symbol table to see if there's an IO object
associated with it, and if so, it replaces the left-hand parameter
with a reference to that object.
note that STDIN->foo() parses in exactly the same way as Package->foo(),
the magic happens at execution time.
Yes, this means that if you open a filehandle with the same name as a
package, then class method calls to the package will break (from within
the current package). Also, it means that you can't define "package STDOUT;"
and expect it to work.
The IO objects that are stored in the *foo{IO} slots of typeglobs are
blessed into package IO::Handle by default, unless...
Logan> Actually, I just tracked it down, and apparently (part of?)
Logan> what happens is that FileHandle.pm does this:
Logan> # Rebless standard file handles
Logan> bless *STDIN{IO}, "FileHandle" if ref *STDIN{IO} eq "IO::Handle";
Logan> bless *STDOUT{IO}, "FileHandle" if ref *STDOUT{IO} eq "IO::Handle";
Logan> bless *STDERR{IO}, "FileHandle" if ref *STDERR{IO} eq "IO::Handle";
...you include FileHandle.pm, in which case they are blessed into
package FileHandle instead. (Once FileHandle is loaded, any new IO
objects created are blessed into FileHandle too; the existence of the
FileHandle symbol table is sufficient to cause that.)
--
Andrew.
------------------------------
Date: Thu, 29 Mar 2001 09:34:08 +0800
From: <jackkon@pchome.com.tw>
Subject: cannot fork?
Message-Id: <99u3n1$jo@netnews.hinet.net>
hi.....all
I adopt some code from my book and run it.
I run the server.pl first and then client.pl.
When the client.pl runs, I find the error below
"Uncaught exception from user code:
cannot fork: Illegal seek"
my system is linux6.2
How can I solve it. Thanks :)
======================================================
##server.pl
use IO::Socket;
use diagnostics;
$SIG{CHLD}=sub{wait()};
$main_sock=new IO::Socket::INET(
LocalHost => '90.0.0.1', ## not my system ip, just a fake ^^
LocalPort => 9800,
Listen => 5,
Proto => 'tcp',
Reuse =>1
);
die "Socket could not be created. Reason: $!\n" unless ($main_sock);
while($new_sock=$main_sock->accept()){
$pid=fork();
die "cannot fork: $!\n" unless ($pid);
if($pid==0){ ##child process
while(defined($buf=<$new_sock>)){
print $new_sock "You said: $buf\n";
}
exit(0); ##end child process
}
}
close($main_sock);
======================================================
##client.pl
use IO::Socket;
use diagnostics;
$sock=new IO::Socket::INET(PeerAddr =>'90.0.01', ## not my system ip,
just a fake ^^
PeerPort =>9800,
Proto =>'tcp',
);
die "Socket could't be create. Reason: $!\n" unless $sock;
foreach(AAA..ZZZ){
print $sock "Msg $_: How are you?\n";
}
close($sock);
===========================================================
------------------------------
Date: Thu, 29 Mar 2001 08:32:38 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: cannot fork?
Message-Id: <slrn9c5sp4.o4s.tjla@thislove.dyndns.org>
I was shocked! How could jackkon@pchome.com.tw <jackkon@pchome.com.tw>
say such a terrible thing:
>hi.....all
>I adopt some code from my book and run it.
>I run the server.pl first and then client.pl.
>When the client.pl runs, I find the error below
>"Uncaught exception from user code:
> cannot fork: Illegal seek"
That error message makes no sense. Why would you be unable to fork
because of an illegal seek?
> $pid=fork();
> die "cannot fork: $!\n" unless ($pid);
This could be your problem. $pid is going to be zero for the parent and
non-zero for the child. In an error condition it is undefined.
Therefore, what you are doing is causing the parent process to die, for
no good reason. The "illegal seek" bit is probably spurious". You might want:
$pid = fork;
unless defined $pid die "Cannot fork: $!";
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
What is worth doing is worth the trouble of asking somebody to do it.
------------------------------
Date: 29 Mar 2001 04:46:09 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: cannot fork?
Message-Id: <m166gsspym.fsf@halfdome.holdit.com>
>>>>> "Gwyn" == Gwyn Judd <tjla@guvfybir.qlaqaf.bet> writes:
Gwyn> $pid = fork;
Gwyn> unless defined $pid die "Cannot fork: $!";
Except you'd probably want to use legal Perl syntax there as well. :)
$pid = fork;
defined $pid or die "cannot fork: $!";
I can't quite figure out just where you were going with yours... :)
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Thu, 29 Mar 2001 20:30:03 -0000
From: [DaVinci] <davinci@gmx.at>
Subject: cgi/perl sendmail problem
Message-Id: <tc76qbp1kjo2e1@corp.supernews.com>
Hi
I have a problem using a mailinglist cgi running on mydomain.com
the thing is it will only send email to recipients who are *@mydomain.com
and not to *@otherdomains.com. Like he only wants to send 'local' email.
Anyone any idea how to solve this?
--
Posted via CNET Help.com
http://www.help.com/
------------------------------
Date: Thu, 29 Mar 2001 20:37:30 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: cgi/perl sendmail problem
Message-Id: <slrn9c778a.72v.abigail@tsathoggua.rlyeh.net>
[DaVinci] (davinci@gmx.at) wrote on MMDCCLXVII September MCMXCIII in
<URL:news:tc76qbp1kjo2e1@corp.supernews.com>:
}} Hi
}}
}} I have a problem using a mailinglist cgi running on mydomain.com
}} the thing is it will only send email to recipients who are *@mydomain.com
}} and not to *@otherdomains.com. Like he only wants to send 'local' email.
}}
}} Anyone any idea how to solve this?
Configure your MTA.
Personally, I'd start configuring sendmail by removing it and replace
it by something sane.
However, this has no relevance to this group.
Abigail
------------------------------
Date: Thu, 29 Mar 2001 11:44:52 GMT
From: "Waarddebon" <Waarddebon@chello.nl>
Subject: changing time/date
Message-Id: <UeFw6.33739$j_4.537144@Flipper>
How to change the time and date of a file (filename stored in a variable
called $file) to the current time and date ??
Thanks in advance..
Ps. I want to change it from within a perl script.
------------------------------
Date: Thu, 29 Mar 2001 14:42:58 +0200
From: "Peter Søgaard" <peter.s@tjgroup.dk>
Subject: Re: changing time/date
Message-Id: <99vadh$qoi$1@news.inet.tele.dk>
"Waarddebon" <Waarddebon@chello.nl> skrev i en meddelelse
news:UeFw6.33739$j_4.537144@Flipper...
> How to change the time and date of a file (filename stored in a variable
> called $file) to the current time and date ??
>
> Thanks in advance..
> Ps. I want to change it from within a perl script.
>
>
$now = time;
utime $now, $now, $file;
------------------------------
Date: Thu, 29 Mar 2001 14:43:35 +0200
From: "Peter Søgaard" <peter.s@tjgroup.dk>
Subject: Re: changing time/date
Message-Id: <99vadr$r15$1@news.inet.tele.dk>
"Waarddebon" <Waarddebon@chello.nl> skrev i en meddelelse
news:UeFw6.33739$j_4.537144@Flipper...
> How to change the time and date of a file (filename stored in a variable
> called $file) to the current time and date ??
>
> Thanks in advance..
> Ps. I want to change it from within a perl script.
>
>
$now = time;
utime $now, $now, $file;
------------------------------
Date: Thu, 29 Mar 2001 13:50:36 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: changing time/date
Message-Id: <slrn9c6fdc.fl2.garry@zfw.zvolve.net>
On Thu, 29 Mar 2001 11:44:52 GMT, Waarddebon <Waarddebon@chello.nl> wrote:
> How to change the time and date of a file (filename stored in a variable
> called $file) to the current time and date ??
Check the perlfunc manual page and look for utime().
--
Garry Williams
------------------------------
Date: 29 Mar 2001 08:52:48 GMT
From: "Scott R. Godin" <webmaster@webdragon.unmunge.net>
Subject: Re: check prototype error
Message-Id: <99ut50$i05$2@216.155.33.15>
In article <0fq1ctgvr7qnii9gbp94qs8tnekeevirqm@4ax.com>,
Bart Lateur <bart.lateur@skynet.be> wrote:
| See? Either you don't use the prototypes, if you don't need them; you
| move the sub definition more upfront; you define it in a module that you
| load; or you add a prototype. The trick is to let perl know about the
| prototype before the function call gets even compiled.
|
| So these will do:
|
| A: # function prototype in front of call
| sub foo ($);
| foo('Bart');
|
| sub foo ($) {
| print "Hi there $_[0]!\n";
| }
| B: # sub definition in front of call
| sub foo ($) {
| print "Hi there $_[0]!\n";
| }
| foo('Bart');
there's also
use subs qw/ foo($) /;
foo('Bart');
sub foo ($)
{
print "Hi there $_[0]!\n";
}
:)
--
unmunge e-mail here:
#!perl -w
print map {chr(ord($_)-3)} split //, "zhepdvwhuCzhegudjrq1qhw";
# ( damn spammers. *shakes fist* take a hint. =:P )
------------------------------
Date: Thu, 29 Mar 2001 13:55:58 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: check prototype error
Message-Id: <slrn9c6fne.fl2.garry@zfw.zvolve.net>
On Tue, 27 Mar 2001 14:02:14 -0500, Philip Tanner
<ptanner@sw.stratus.com> wrote:
> I recently upgraded my site from perl 5.003.03 to 5.6. I just got
> mail from one of our developers saying he's seeing the following
> errors with the new version:
>
> main::foo() called too early to check prototype at foo1 line 235
>
> Is this a problem with the way I compiled perl (all the tests ran
> fine after the build), or is it a bug in his script?
It's a bug in the script that was not not a warning in the older
version of perl.
The perldelta manual page mentions the new warning.
--
Garry Williams
------------------------------
Date: 29 Mar 2001 01:58:25 GMT
From: anotherway83@aol.com (The Mosquito ScriptKiddiot)
Subject: Re: date handling?
Message-Id: <20010328205825.28057.00002239@ng-mi1.aol.com>
>Subject: Re: date handling?
d00d...if u can't handle ur dates, then stop dating
btw, what does dating have to do with this NG...
lol, sorry just kidding
peace
The Mosquito ScriptKiddiot
Championing the Cause of Mosquitoes in Technology
------------------------------
Date: Thu, 29 Mar 2001 13:47:31 +0200
From: "Peter" <peter@venturenet.co.za>
Subject: Deleting a line from a Flat Text File
Message-Id: <3ac3209a$0$228@hades.is.co.za>
Plse can somebody tell me how to remove a line from a FTF. This line must
match a certain string. Please help me in this perl project.
------------------------------
Date: Thu, 29 Mar 2001 11:58:43 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Deleting a line from a Flat Text File
Message-Id: <slrn9c68pj.2of.bernard.el-hagin@gdndev32.lido-tech>
On Thu, 29 Mar 2001 13:47:31 +0200, Peter <peter@venturenet.co.za> wrote:
>Plse can somebody tell me how to remove a line from a FTF. This line must
>match a certain string. Please help me in this perl project.
This is in the FAQ. Try perldoc -q 'one line'.
Cheers,
Bernard
--
#requires 5.6.0
perl -le'* = =[[`JAPH`]=>[q[Just another Perl hacker,]]];print @ { @ = [$ ?] }'
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 587
**************************************