[19960] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 2155 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 19 06:05:39 2001

Date: Mon, 19 Nov 2001 03:05:09 -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: <1006167908-v10-i2155@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 19 Nov 2001     Volume: 10 Number: 2155

Today's topics:
    Re: (Newbie question) Premature end of script headers   <peb@bms.umist.ac.uk>
        (Newbie question) Premature end of script headers arggg <wrightkevin@ntlworld.com>
    Re: (Newbie question) Premature end of script headers a <ron@savage.net.au>
    Re: (Newbie question) Premature end of script headers a <comdog@panix.com>
    Re: Binary issues.. <mds@wam.umd.edu>
    Re: Binary issues.. <mgjv@tradingpost.com.au>
    Re: Directory problem... again (BUCK NAKED1)
    Re: Directory problem... again <uri@stemsystems.com>
    Re: Directory problem... again <mgjv@tradingpost.com.au>
        Dynamic Two-Dimensional Array Creation? <sagarwal@rr.com>
    Re: Dynamic Two-Dimensional Array Creation? <uri@stemsystems.com>
    Re: Dynamic Two-Dimensional Array Creation? <pne-news-20011119@newton.digitalspace.net>
    Re: How can I use LWP::Simple inside a safe compartment <skradel@mindspring.common.sense>
        How do I implement non-blocking IO on Win32? <kgouldsk@altavista.com>
    Re: HTTP Server using Sockets <ilya@martynov.org>
    Re: need help with simple script <khirv@hotmail.com>
    Re: need help with simple script <mgjv@tradingpost.com.au>
        Newbie module problem (Perry Wheeler)
    Re: perl cgi question: <comdog@panix.com>
    Re: perl script for finding users nobull@mail.com
        Resolving directory name <email@timlauterborn.de>
    Re: Resolving directory name <Tassilo.Parseval@post.rwth-aachen.de>
    Re: Resolving directory name <email@timlauterborn.de>
        separate cgi file for subroutines <jonah@@adtrackz.com>
    Re: subroutines in separate file (Tad McClellan)
    Re: temporary file deleting too soon nobull@mail.com
    Re: Which ISPs support perl scripts? <spam@phased.co.uk>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Mon, 19 Nov 2001 09:53:50 +0000
From: Paul Boardman <peb@bms.umist.ac.uk>
Subject: Re: (Newbie question) Premature end of script headers  arggggggggggggggggg!
Message-Id: <3BF8D6AE.8ADC5B7F@bms.umist.ac.uk>

wrightkevin wrote:

> Apologies if this is the wrong group.

some people would point you towards comp.infosystems.www.authoring.cgi 
but there have been problems with this group (which I think are sorted
out now).
 

> I've tried to write the simplest perl cgi-script I could come up with
> I have transferred it in ascii mode. Think the permissions are ok!
> 
> Here is the code:
> 
> #!/usr/bin/perl
> print "Content-type: text/html\n\n";
> print "They dont get much simpler than this";

Seems pretty simple to me.

> Here is the error log:
> 
> [Mon Nov 19 00:41:58 2001] [error] [client 62.252.0.5] Premature end of
> script headers: /data/wrightkevin/cgi-bin/s2.pl
> [Mon Nov 19 00:41:58 2001] [error] [client 62.252.0.5] MOD_VR9: Error 500
> occured while processing : /data/wrightkevin/cgi-bin/s2.pl
> 
> I have tried ftp'ing the file to home home and home/cgi-bin directories.
> (No difference)
> 
> I have looked up this error on google and elsewhere and have found that I am
> not the first programmer to encounter this message but I am still none the
> wiser.

The 500 (Premature end of script headers) must be the most common
error.  It usually means that there is output before the headers (error
messages) or that the headers are not outputed at all.  

A few things spring to mind that may be the cause of the error.

Have you tried running your script from the command line on the server
(do you have access to the command line?).  Are you sure that the perl
binary is located at /usr/bin/perl ?

Paul


------------------------------

Date: Mon, 19 Nov 2001 08:36:59 -0000
From: "wrightkevin" <wrightkevin@ntlworld.com>
Subject: (Newbie question) Premature end of script headers arggggggggggggggggg!
Message-Id: <Ow3K7.16656$%p4.2101124@news6-win.server.ntlworld.com>

Hi,

Apologies if this is the wrong group.

I've tried to write the simplest perl cgi-script I could come up with
I have transferred it in ascii mode. Think the permissions are ok!


Here is the code:

#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "They dont get much simpler than this";


Here is the error log:

[Mon Nov 19 00:13:15 2001] [error] [client 62.252.0.5] Premature end of
script headers: /data/wrightkevin/s2.pl
[Mon Nov 19 00:13:15 2001] [error] [client 62.252.0.5] MOD_VR9: Error 500
occured while processing : /data/wrightkevin/s2.pl
[Mon Nov 19 00:13:29 2001] [error] [client 62.252.0.5] Premature end of
script headers: /data/wrightkevin/s2.pl
[Mon Nov 19 00:13:29 2001] [error] [client 62.252.0.5] MOD_VR9: Error 500
occured while processing : /data/wrightkevin/s2.pl
[Mon Nov 19 00:14:31 2001] [error] [client 62.252.0.5] Premature end of
script headers: /data/wrightkevin/cgi-bin/s2.pl
[Mon Nov 19 00:14:31 2001] [error] [client 62.252.0.5] MOD_VR9: Error 500
occured while processing : /data/wrightkevin/cgi-bin/s2.pl
[Mon Nov 19 00:33:07 2001] [error] [client 62.252.0.5] Premature end of
script headers: /data/wrightkevin/cgi-bin/s2.pl
[Mon Nov 19 00:33:07 2001] [error] [client 62.252.0.5] MOD_VR9: Error 500
occured while processing : /data/wrightkevin/cgi-bin/s2.pl
[Mon Nov 19 00:41:58 2001] [error] [client 62.252.0.5] Premature end of
script headers: /data/wrightkevin/cgi-bin/s2.pl
[Mon Nov 19 00:41:58 2001] [error] [client 62.252.0.5] MOD_VR9: Error 500
occured while processing : /data/wrightkevin/cgi-bin/s2.pl


I have tried ftp'ing the file to home home and home/cgi-bin directories.
(No difference)


I have looked up this error on google and elsewhere and have found that I am
not the first programmer to encounter this message but I am still none the
wiser.
Please help.

Thank you.

Kevin Wright.





------------------------------

Date: Mon, 19 Nov 2001 20:35:14 +1100
From: "Ron Savage" <ron@savage.net.au>
Subject: Re: (Newbie question) Premature end of script headers arggggggggggggggggg!
Message-Id: <En4K7.738$li3.29964@ozemail.com.au>

Perhaps your Perl is not in /usr/bin/perl.

Your program - if in fact it is precisely your program - ran fine for me.

--
Cheers
Ron Savage
ron@savage.net.au
http://savage.net.au/index.html
"wrightkevin" <wrightkevin@ntlworld.com> wrote in message news:Ow3K7.16656$%p4.2101124@news6-win.server.ntlworld.com...
> Hi,
>
> Apologies if this is the wrong group.
>
> I've tried to write the simplest perl cgi-script I could come up with
> I have transferred it in ascii mode. Think the permissions are ok!
>
>
> Here is the code:
>
> #!/usr/bin/perl
> print "Content-type: text/html\n\n";
> print "They dont get much simpler than this";
>
>
> Here is the error log:
>
> [Mon Nov 19 00:13:15 2001] [error] [client 62.252.0.5] Premature end of
> script headers: /data/wrightkevin/s2.pl
> [Mon Nov 19 00:13:15 2001] [error] [client 62.252.0.5] MOD_VR9: Error 500
> occured while processing : /data/wrightkevin/s2.pl
> [Mon Nov 19 00:13:29 2001] [error] [client 62.252.0.5] Premature end of
> script headers: /data/wrightkevin/s2.pl
> [Mon Nov 19 00:13:29 2001] [error] [client 62.252.0.5] MOD_VR9: Error 500
> occured while processing : /data/wrightkevin/s2.pl
> [Mon Nov 19 00:14:31 2001] [error] [client 62.252.0.5] Premature end of
> script headers: /data/wrightkevin/cgi-bin/s2.pl
> [Mon Nov 19 00:14:31 2001] [error] [client 62.252.0.5] MOD_VR9: Error 500
> occured while processing : /data/wrightkevin/cgi-bin/s2.pl
> [Mon Nov 19 00:33:07 2001] [error] [client 62.252.0.5] Premature end of
> script headers: /data/wrightkevin/cgi-bin/s2.pl
> [Mon Nov 19 00:33:07 2001] [error] [client 62.252.0.5] MOD_VR9: Error 500
> occured while processing : /data/wrightkevin/cgi-bin/s2.pl
> [Mon Nov 19 00:41:58 2001] [error] [client 62.252.0.5] Premature end of
> script headers: /data/wrightkevin/cgi-bin/s2.pl
> [Mon Nov 19 00:41:58 2001] [error] [client 62.252.0.5] MOD_VR9: Error 500
> occured while processing : /data/wrightkevin/cgi-bin/s2.pl
>
>
> I have tried ftp'ing the file to home home and home/cgi-bin directories.
> (No difference)
>
>
> I have looked up this error on google and elsewhere and have found that I am
> not the first programmer to encounter this message but I am still none the
> wiser.
> Please help.
>
> Thank you.
>
> Kevin Wright.
>
>
>




------------------------------

Date: Mon, 19 Nov 2001 03:46:19 -0600
From: brian d foy <comdog@panix.com>
Subject: Re: (Newbie question) Premature end of script headers arggggggggggggggggg!
Message-Id: <comdog-1932E3.03461919112001@news.panix.com>

[follow-ups set]

In article <Ow3K7.16656$%p4.2101124@news6-win.server.ntlworld.com>, 
"wrightkevin" <wrightkevin@ntlworld.com> wrote:


> Apologies if this is the wrong group.

indeed it is.  try comp.infosystems.www.authoring.cgi :)

have you tried the troubleshooting guides in the CGI Meta FAQ?

-- 
brian d foy <comdog@panix.com> - Perl services for hire
CGI Meta FAQ - http://www.perl.org/CGI_MetaFAQ.html
Troubleshooting CGI scripts - http://www.perl.org/troubleshooting_CGI.html



------------------------------

Date: Mon, 19 Nov 2001 01:17:16 -0500
From: "Mike Schmitt" <mds@wam.umd.edu>
Subject: Re: Binary issues..
Message-Id: <9ta869$lim$1@hecate.umd.edu>

Martien Verbruggen wrote in message ...
>I just thought of a much, much simpler way. It allows you less control
>over how much memory you need, but it makes life much simpler to deal
>with.

This is basically what my code looks like already;  it reads the whole HTML
file into a scalar (in binmode), splits it at every <data> and <hR>**, and
then uses regex's to process down the resulting arrays.  the problem is, it
uses an immense amount of memory.
Your previous idea seems like the best; that is, set a variable such as
$old_end to "" at the beginning of the program, read the first meg into
$line, test $old_end . $line, read the last 6 bytes of $line into $old_end,
loop back, and do the whole thing over again.  Then whenever a match is
found, I can just pass it into the regex function I already wrote as a part
of the non-memory-efficient version of the program  ;-)




------------------------------

Date: Mon, 19 Nov 2001 19:56:10 +1100
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Binary issues..
Message-Id: <slrn9vhi9a.mfo.mgjv@martien.heliotrope.home>

On Mon, 19 Nov 2001 01:17:16 -0500,
	Mike Schmitt <mds@wam.umd.edu> wrote:
> Martien Verbruggen wrote in message ...
>>I just thought of a much, much simpler way. It allows you less control
>>over how much memory you need, but it makes life much simpler to deal
>>with.
> 
> This is basically what my code looks like already;  it reads the whole HTML
> file into a scalar (in binmode), splits it at every <data> and <hR>**, and
> then uses regex's to process down the resulting arrays.  the problem is, it
> uses an immense amount of memory.

But my code doesn't read in the _whole_ file in a single scalar. It
reads the file bit by bit. The bits are defined as being separated by
whatever is in $/:

$/ = "</data>";

The largest amount of memory used would be approximately twice the
largest amount of data between </data> tokens. The problem is that that
has to be a fixed string. I'm not sure what you mean by <hR>** but if
those ** are supposed to be some sort of wildcard, this approach
wouldn't work (unless you're certain that <hR> does not appear anywhere
else. In that case you could do:

$/ = "</hR>";

while (<>)
{
    chomp;
    substr $_, 0, 2 = "";
    # Do stuff with $_
}
)

BTW, the $/ variable is described int he perlvar documentation.

> Your previous idea seems like the best; that is, set a variable such as
> $old_end to "" at the beginning of the program, read the first meg into
> $line, test $old_end . $line, read the last 6 bytes of $line into $old_end,
> loop back, and do the whole thing over again.  Then whenever a match is
> found, I can just pass it into the regex function I already wrote as a part
> of the non-memory-efficient version of the program  ;-)

This approach is fine, and has the advantage that it translates easier
into other languages. It also has the disadvantage that it's slightly
more complex.

Martien
-- 
                        | 
Martien Verbruggen      | I'm just very selective about what I accept
                        | as reality - Calvin
                        | 


------------------------------

Date: Sun, 18 Nov 2001 22:44:49 -0600 (CST)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: Directory problem... again
Message-Id: <27592-3BF88E41-27@storefull-243.iap.bryant.webtv.net>

uri@stemsystems.com (Uri=A0Guttman) 
> utime modifies the time stamps of a 
> single file. notice the plural use of 
> 'timestamps'. 
> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0utime LIST 
>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0Changes the access and 
> modification times on each file of a list =A0 >=A0 of files. 
> ok, you pass to utime a list. you do 
> know what a list is in perl. i know you 
> know. notice that you can pass 
> MULTIPLE files. you can't rename 
> multiple files in one call so it only takes > oldfile and newfile. 
>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0The first two elements
of the 
> list must be the NUMERICAL access =A0 =A0 > and modification times, in
that order. 
> so, element one must be the access 
> time. element two must be the 
> modification time. then the REST of the > list must be the files to
set the times on. > is that clear? 
> and the reason you need both times is 
> because otherwise how could you set 
> one time and not the other without 2 
> separate calls? utime sets BOTH times. > so you must pass 2 time
values. 
> if you want to keep one the same, then > you read the times with stat
and use a 
> current time value for one of the 
> arguments. simple. 
<snip>
> utime takes 2 times so you can set 
> either or both of them in one call. it 
> takes multiple files since you can set the > times on all of them
without writing your > own loop. so how do you demark which > arguments
are the times and which are > the files? well, you ALWAYS need 2 
> time arguments so you make them the 
> first 2 in the list. 

Thank you. I completely understand utime now. That was a fantastic
explanation and proof of exactly what I was saying about the
unthoroughness of some of the docs. If all the docs were written that
well, I think I'd have little problem understanding them. You made UTIME
very easy to understand. Perhaps the above should be edited a bit and
replace the perldoc -f utime. Got time to rewrite some of the other
docs? <smile>
   
> i have definitely offered you help.

Maybe so. Perhaps, I was wrong about you after all. I'll raise your
score back up a few knotches. ;-)

Regards,
Dennis

"I don't understand... whas yo plan... that you can't be... good to me"
-Tina Turner



------------------------------

Date: Mon, 19 Nov 2001 05:39:48 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Directory problem... again
Message-Id: <x73d3bfhcv.fsf@home.sysarch.com>

>>>>> "BN" == BUCK NAKED1 <dennis100@webtv.net> writes:

  BN> Thank you. I completely understand utime now. That was a fantastic
  BN> explanation and proof of exactly what I was saying about the
  BN> unthoroughness of some of the docs. If all the docs were written that
  BN> well, I think I'd have little problem understanding them. You made UTIME
  BN> very easy to understand. Perhaps the above should be edited a bit and
  BN> replace the perldoc -f utime. Got time to rewrite some of the other
  BN> docs? <smile>
   
i don't want to rewrite the docs. but i deduced all that from reading
the doc on utime. i don't think i have ever called it in a program in my
career (in c or perl). the point martien was maming is that there is a
definite logic to api design and their docs. yes, many are dry and
poorly written. but you can deduce its meaning and proper use by
understanding the goal of the call.

this is a skill that you have to develop. there will never be enough
people around to explain docs to you. so learn how to read them better
and read between the lines. why did the api get designed this way? what
is the purpose of each arg? do i need to set all the args?

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
-- Stem is an Open Source Network Development Toolkit and Application Suite -
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


------------------------------

Date: Mon, 19 Nov 2001 21:19:54 +1100
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Directory problem... again
Message-Id: <slrn9vhn6a.mfo.mgjv@martien.heliotrope.home>

On Mon, 19 Nov 2001 05:39:48 GMT,
	Uri Guttman <uri@stemsystems.com> wrote:
>>>>>> "BN" == BUCK NAKED1 <dennis100@webtv.net> writes:
> 
>  BN> Thank you. I completely understand utime now. That was a fantastic
>  BN> explanation and proof of exactly what I was saying about the
>  BN> unthoroughness of some of the docs. If all the docs were written that
>  BN> well, I think I'd have little problem understanding them. You made UTIME
>  BN> very easy to understand. Perhaps the above should be edited a bit and
>  BN> replace the perldoc -f utime. Got time to rewrite some of the other
>  BN> docs? <smile>
>    
> i don't want to rewrite the docs. but i deduced all that from reading
> the doc on utime. i don't think i have ever called it in a program in my
> career (in c or perl). the point martien was maming is that there is a
> definite logic to api design and their docs. yes, many are dry and
> poorly written. but you can deduce its meaning and proper use by
> understanding the goal of the call.

Another point I'll make now is that I don't even want the documentation
to become a tutorial on every little piece of arcana about Perl and Unix
system calls. The documentation is a reference, and it shouldn't be
more. Yes, some of the documentation is insufficient, but the
documentation on utime isn't, as far as I'm concerned. Even after
rereading it again, trying to ban all knowledge of Perl and Unix from my
head, and to only rely on English parsing (which isn't my first
language) I still fail to miss the fact that the first two arguments are
documented to represent two different times.

The perl documentation is a technical reference, and that is what they
should remain.  There are good tutorials and learning Perl books out
there to explain everything in detail. I don't want to have to wade
through loads of verbosity every time I want to look something up. The
standards docs should be succinct, precise, up to date, and correct. No
more.

Most of the work in the documentation should go into achieving those
goals. Any other stuff should go into books, or maybe one of the
perl*tut documents.

> this is a skill that you have to develop. there will never be enough
> people around to explain docs to you. so learn how to read them better
> and read between the lines. why did the api get designed this way? what
> is the purpose of each arg? do i need to set all the args?

In the case of utime this may be hard without understanding a subset of
the Unix system calls, which aren't always totally logical. I do agree
that reading a language's documentation is a skill you will have to
have. If at first read you don't understand, read again. Then read
again. Then write some lines of code, and experiment. Then read again.
It sometimes takes time to let things sink in. Give it time.

Martien
-- 
                        | 
Martien Verbruggen      | You can't have everything, where would you
                        | put it?
                        | 


------------------------------

Date: Mon, 19 Nov 2001 05:28:22 GMT
From: "Subodh Bhargava" <sagarwal@rr.com>
Subject: Dynamic Two-Dimensional Array Creation?
Message-Id: <WL0K7.1178623$si5.44468245@typhoon.kc.rr.com>

Is it possible to create a dynamic two-dimensional array in Perl? I have a
requirement where I don't know the size of the two-dimensional array I want
to create. I will get to know the length of each dimension only when my
program runs. It depends on the kind of file which it is going to read; and
which is I don't know upfront.

Any pointers in this regard will be highly appreciated..

Thanks in advance,
Subodh




------------------------------

Date: Mon, 19 Nov 2001 05:40:44 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Dynamic Two-Dimensional Array Creation?
Message-Id: <x7zo5je2qv.fsf@home.sysarch.com>

>>>>> "SB" == Subodh Bhargava <sagarwal@rr.com> writes:

  SB> Is it possible to create a dynamic two-dimensional array in Perl?
  SB> I have a requirement where I don't know the size of the
  SB> two-dimensional array I want to create. I will get to know the
  SB> length of each dimension only when my program runs. It depends on
  SB> the kind of file which it is going to read; and which is I don't
  SB> know upfront.

nah, perl is too stupid to do such a complex thing. :)

read perllol for examples. it is easy.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
-- Stem is an Open Source Network Development Toolkit and Application Suite -
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


------------------------------

Date: Mon, 19 Nov 2001 10:14:27 +0100
From: Philip Newton <pne-news-20011119@newton.digitalspace.net>
Subject: Re: Dynamic Two-Dimensional Array Creation?
Message-Id: <i9ihvt4ldi9clpcmq5hri7f8l52in0a69q@4ax.com>

On Mon, 19 Nov 2001 05:40:44 GMT, Uri Guttman <uri@stemsystems.com>
wrote:

> >>>>> "SB" == Subodh Bhargava <sagarwal@rr.com> writes:
> 
>   SB> Is it possible to create a dynamic two-dimensional array in Perl?
>   SB> I have a requirement where I don't know the size of the
>   SB> two-dimensional array I want to create. I will get to know the
>   SB> length of each dimension only when my program runs. It depends on
>   SB> the kind of file which it is going to read; and which is I don't
>   SB> know upfront.
> 
> nah, perl is too stupid to do such a complex thing. :)

Nonsense, you just have to use pointers instead of arrays and then
'malloc' the space yourself once you know the size.

> read perllol for examples. it is easy.

Seriously now: Uri's right. It's easy. For example, you can use 'push'
or 'shift' to extend arbitrary dimensions, or just assign to elements
and they'll spring into existence.

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


------------------------------

Date: Mon, 19 Nov 2001 02:14:21 -0500
From: "Steve K" <skradel@mindspring.common.sense>
Subject: Re: How can I use LWP::Simple inside a safe compartment?
Message-Id: <9tabge$geu$1@slb7.atl.mindspring.net>


"BUCK NAKED1" <dennis100@webtv.net> wrote in message
news:26901-3BF6E521-41@storefull-244.iap.bryant.webtv.net...
> Shouldn't that be
>
> use LWP::Simple;
>
> NOT use LWP::Simple();

Nah.  The latter says "load up LWP::Simple but don't pollute my namespace
with that package's functions and stuff, because I'll write for objects or
specify the package name when appropriate."

Steve

>
> --Dennis
>




------------------------------

Date: Mon, 19 Nov 2001 06:20:22 GMT
From: "Kevin Gould" <kgouldsk@altavista.com>
Subject: How do I implement non-blocking IO on Win32?
Message-Id: <Gw1K7.1178661$si5.44533621@typhoon.kc.rr.com>

I'm trying to write a parent/child script that will run as a service on
Win32.  I need the child to write data back to the parent, but the parent
needs to perform other functions between polling for data from the child, so
I need to do non-blocking IO.  I'm using a routine from Lincoln Stein's
excellent "Network Programming with Perl", but am having some trouble with
the Fcntl module.

It appears that Fcntl on Win32 doesn't implement what I need.

F:\data\perl\examples\IO>non-block-ipc.pl
Forking a child process
This is the child speaking
Your vendor has not defined Fcntl macro F_GETFL, used at
F:\data\perl\examples\I
O\non-block-ipc.pl line 77.


sub BlockOff {
   my ($handle,$blocking)=@_;
   die "Can't fcntl (F_GETFL)" unless
   my $flags= fcntl($handle,F_GETFL,0);
   my $current=($flags & O_NONBLOCK) == 0;
   if (defined $blocking) {
      $flags&= ~O_NONBLOCK if $nonblocking;
      $flags|+ O_NONBLOCK unless $blocking;
      die "Can't fcntl (F_SETFL)" unless fcntl($handle,F_SETFL,$flags);
   }

   return $current;

}



Can anyone suggest an alternate method for implementing non-blocking IO?




------------------------------

Date: 19 Nov 2001 13:43:21 +0300
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: HTTP Server using Sockets
Message-Id: <87pu6fca7q.fsf@abra.ru>

>>>>> On Mon, 19 Nov 2001 09:47:49 +0530, "Rohit Nadhani" <rohit.nadhani@tallysolutions.com> said:

Rohit> Hi,
Rohit> I am new to Perl and am trying to develop a HTTP server using sockets.

Rohit> Everything works fine till accept(), but I don't know how to read the
Rohit> complete HTTP POST and then send a response back to the client.

Don't reinvent the wheel. Use HTTP::Daemon as basis for your server.

-- 
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/)          TIV.net (http://tiv.net/) |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80  E4AE BE1A 53EB 323B DEE6 |
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


------------------------------

Date: Mon, 19 Nov 2001 15:08:37 +0800
From: "blongk" <khirv@hotmail.com>
Subject: Re: need help with simple script
Message-Id: <3bf8b062$1_2@news.tm.net.my>

I apologize for the mistake and thank you for reminding me. However I can
not find your post that answered my question. Please tell me the date of the
post and what the subject was. Thank you again.

"Martien Verbruggen" <mgjv@tradingpost.com.au> wrote in message
news:slrn9v184p.6ia.mgjv@verbruggen.comdyn.com.au...
> On Tue, 13 Nov 2001 11:58:42 +0800,
> blongk <khirv@hotmail.com> wrote:
> > I have a perl script that lists the hash keys and the values like this:
>
> You just posted this question, and I have just answered it. Please try
> to not post the same question more than once. Even if it doesn't show
> up right away in your news reader, wait a little while before
> concluding that the post went wrong. Usenet isn't instantaneous.
>
> Thanks,
>
> Martien
> --
>                                 |
> Martien Verbruggen              | That's not a lie, it's a
> Trading Post Australia Pty Ltd  | terminological inexactitude.
>                                 |




------------------------------

Date: Mon, 19 Nov 2001 21:22:50 +1100
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: need help with simple script
Message-Id: <slrn9vhnbq.mfo.mgjv@martien.heliotrope.home>

On Mon, 19 Nov 2001 15:08:37 +0800,
	blongk <khirv@hotmail.com> wrote:
> I apologize for the mistake and thank you for reminding me. However I can
> not find your post that answered my question. Please tell me the date of the
> post and what the subject was. Thank you again.

[Please do not top-post]

search on groups.google.com for the Subject of this post and my last
name, gives me this:

Message-ID: <slrn9v178l.6ia.mgjv@verbruggen.comdyn.com.au>

Martien
-- 
                        | 
Martien Verbruggen      | I took an IQ test and the results were
                        | negative.
                        | 


------------------------------

Date: 19 Nov 2001 01:56:24 -0800
From: pwheeler@kentports.org (Perry Wheeler)
Subject: Newbie module problem
Message-Id: <ab5c4b00.0111190156.7f54d81e@posting.google.com>

Sorry to cross-post, I originally posted this on 'modules last week
but didn't get anywhere.


Hi,

Possibly I shouldn't be trying to run before I can walk but here's the
problem.

I've written a short perl script to get stock prices and email the
results to an sms gateway service based on the Finance::Quote module
from CPAN.

The script works (it runs on my proxy server) without any problem. I
can telnet to the server, su, run the thing and a couple of minutes
later I get an sms message to my phone with the result.

Trouble is I can't get the thing to run as scheduled job (I set this
up under Webmin). I set it run as root, so it's not permission based.
An error report is produced as follows (sorry for the long quote):

=======================
Can't locate loadable object for module HTML::Parser in @INC (@INC
contains: /usr/local/lib/perl5/site_perl/5.6.1
/usr/lib/perl5/5.00503/i386-linux /usr/lib/perl5/5.00503
/usr/lib/perl5/site_perl/5.005/i386-linux
/usr/lib/perl5/site_perl/5.005 .) at
/usr/local/lib/perl5/site_perl/5.6.1/HTML/TableExtract.pm line 16
BEGIN failed--compilation aborted at
/usr/local/lib/perl5/site_perl/5.6.1/HTML/TableExtract.pm line 16.
BEGIN failed--compilation aborted at
/usr/local/lib/perl5/site_perl/5.6.1/Finance/Quote/Cdnfundlibrary.pm
line 20.
BEGIN failed--compilation aborted at (eval 3) line 1.
 at pwquote.pl line 36
Can't locate object method "methods" via package
"Finance::Quote::Cdnfundlibrary" at
/usr/local/lib/perl5/site_perl/5.6.1/Finance/Quote.pm line 109.
========================

Parser.pm is present in /usr/local/lib/perl5/site_perl/5.6.1/HTML. Any
help, at novice level would be much appreciated

Thanks

Perry W
psw at kentcoast dot co dot uk


------------------------------

Date: Mon, 19 Nov 2001 03:47:54 -0600
From: brian d foy <comdog@panix.com>
Subject: Re: perl cgi question:
Message-Id: <comdog-CC7F93.03475419112001@news.panix.com>

[follow-ups set]

In article <KpZJ7.2165$yx5.556991@dfiatx1-snr1.gtei.net>, "Scaramouche" 
<e.quesada@verizon.net> wrote:

> my question is two fold.

see the docs in the CGI Meta FAQ, then take further questions
to comp.infosystems.www.authoring.cgi.

-- 
brian d foy <comdog@panix.com> - Perl services for hire
CGI Meta FAQ - http://www.perl.org/CGI_MetaFAQ.html
Troubleshooting CGI scripts - http://www.perl.org/troubleshooting_CGI.html



------------------------------

Date: 19 Nov 2001 02:47:33 -0800
From: nobull@mail.com
Subject: Re: perl script for finding users
Message-Id: <4dafc536.0111190247.17ef6b65@posting.google.com>

thegman54@hotmail.com (AleX) wrote in message news:<2fdf3c7a.0111181537.ba8b4bb@posting.google.com>...
> im looking for anyone that can point me towards a script that will
> query doamin controllers in a specific domain for users that are
> online at the time.

As far as I know this is impossible.  I said this last time this
question was asked here and nobody contradicted me.

> does anyone have any ideas?

I wrote a script to fake this by looking in the domain servers' logs. 
Then, since domain controllers do not know about users who have
"logged out" by rebooting their workstations, I modified it to query
the workstations' logs instead of the domain controllers'.

However the code for merging the logs from multiple domain controllers
is still in the script.

This is _not_ a polished script for publication - it's something I
lashed together to satisfy a specific need.

See http://www.wcl.bham.ac.uk/pub/bam/NT-Status/


------------------------------

Date: Mon, 19 Nov 2001 09:56:30 +0100
From: "Tim Lauterborn" <email@timlauterborn.de>
Subject: Resolving directory name
Message-Id: <9tahg7$qop$1@nets3.rz.RWTH-Aachen.DE>

Hi,

two short questions:

Is there a module or function that resolves a relative filename, for example
that makes '/usr/local/demo' out of '../demo' when I am in a subdirectory of
local?

Does someone know a module that builds a sort of sandbox around a perl
script so that I can not write to a file that is in the root directory for
example?

Thanks!

Greetings
Tim




------------------------------

Date: Mon, 19 Nov 2001 10:36:55 +0100
From: "Tassilo v. Parseval" <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: Resolving directory name
Message-Id: <9tajrn$4pm$01$1@news.t-online.com>

On Mon, 19 Nov 2001 09:56:30 +0100, Tim Lauterborn wrote:
> Hi,
> 
> two short questions:
> 
> Is there a module or function that resolves a relative filename, for example
> that makes '/usr/local/demo' out of '../demo' when I am in a subdirectory of
> local?

Yes, Cwd (stands for Current working directory). More precisely,
Cwd::abs_path.

> Does someone know a module that builds a sort of sandbox around a perl
> script so that I can not write to a file that is in the root directory for
> example?

It is already there and called 'priviliges'. If these are properly set,
a user should never be able to write into the root-dir.

Tassilo
-- 
The price of success in philosophy is triviality.
		-- C. Glymour.


------------------------------

Date: Mon, 19 Nov 2001 12:01:47 +0100
From: "Tim Lauterborn" <email@timlauterborn.de>
Subject: Re: Resolving directory name
Message-Id: <9taor1$474$1@nets3.rz.RWTH-Aachen.DE>

Hi,

all right. Works great.

Thanks.

Greetings,
Tim

"Tassilo v. Parseval" <Tassilo.Parseval@post.rwth-aachen.de> schrieb im
Newsbeitrag news:9tajrn$4pm$01$1@news.t-online.com...
> On Mon, 19 Nov 2001 09:56:30 +0100, Tim Lauterborn wrote:
> > Hi,
> >
> > two short questions:
> >
> > Is there a module or function that resolves a relative filename, for
example
> > that makes '/usr/local/demo' out of '../demo' when I am in a
subdirectory of
> > local?
>
> Yes, Cwd (stands for Current working directory). More precisely,
> Cwd::abs_path.
>
> > Does someone know a module that builds a sort of sandbox around a perl
> > script so that I can not write to a file that is in the root directory
for
> > example?
>
> It is already there and called 'priviliges'. If these are properly set,
> a user should never be able to write into the root-dir.
>
> Tassilo
> --
> The price of success in philosophy is triviality.
> -- C. Glymour.




------------------------------

Date: Mon, 19 Nov 2001 00:07:46 -0800
From: "Jonah" <jonah@@adtrackz.com>
Subject: separate cgi file for subroutines
Message-Id: <Pw0K7.1768$op.521334@news20.bellglobal.com>


Hi

I want to separate the display subroutines into
another file but they need to have access to
the global variables declared in the main script.

The globals are hidden field values and stuff from
the query string.

Is this possible? I have use strict on.

Example: Main CGI script:

#some code here
#declare globals - get them from $q->param('whatever');
#call display subs from other file that have access to global vars

I can't pass the variables through the function parameters
because on each call of the script, the variable list is different, or
sometimes, not used at all. (depending on which button
is clicked) Doing it that way will be tedious at best.
I would have to create a parameter list for every possible
variable, and then put "" for the value when they are not being
used.

Thanks for any help
















------------------------------

Date: Mon, 19 Nov 2001 05:05:30 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: subroutines in separate file
Message-Id: <slrn9vh21o.e9l.tadmc@tadmc26.august.net>

Jonah <jonah@@adtrackz.com> wrote:
>
>I want to separate the display subroutines into
>another file but they need to have access to
>the global variables declared in the main script.
>
>The globals are hidden field values and stuff from
>the query string.
>
>Is this possible? 


Yes. If you insist on using global variables.

But I bet you don't really need global variables. Can't be sure
because you haven't told us much about them.

You should give some serious consideration to alternatives
before resorting to global variables.

If you still think you need them, and there are more than
five or ten, then take yet some more time to see if you
cannot come up with a better way.


>I have use strict on.


That's good. There are a few ways to satisfy strict and still
share the variables:

   our() or "use vars"

   use package names in your subroutines.

To learn about the first one:

   perldoc -f our

   perldoc vars

For the second one, refer to variables as  $main::var  instead of $var.

   perldoc perlmod

There is also a good discussion of Perl variables at:

   http://perl.plover.com/FAQs/Namespaces.html


Finally, you might just do it the Old Fashioned way:

   perldoc -f require

   perldoc -f do


>Example: Main CGI script:
>
>#some code here
>#declare globals - get them from $q->param('whatever');
                        ^^^^

Get *all* of them from $q->param()?

If so, then you won't need global variables.


>#call display subs from other file that have access to global vars
>
>I can't pass the variables through the function parameters
>because on each call of the script, the variable list is different, or


Why not just pass $q as an argument, then have the subroutines
retrieve whatever they need from $q->param()?


>sometimes, not used at all. (depending on which button
>is clicked) 


That does not preclude you from passing them. The subroutine
is free to ignore its arguments.


>Doing it that way will be tedious at best.


Computers are good at automating tedious things for you.


>I would have to create a parameter list 


Or, you could create code to create it _for_ you  :-)


>for every possible
>variable, and then put "" for the value when they are not being
>used.


You could load up a hash with the info and pass the hash.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: 19 Nov 2001 02:03:33 -0800
From: nobull@mail.com
Subject: Re: temporary file deleting too soon
Message-Id: <4dafc536.0111190203.4b028cb9@posting.google.com>

"Gregory Toomey" <nobody@nowhere.com> wrote in message news:<Lh_J7.369152$8x1.109170@newsfeeds.bigpond.com>...
> "Benjamin Goldberg" <goldbb2@earthlink.net> wrote in message
> news:3BF8658D.91D2216C@earthlink.net...
> 
> > Best might be to *not* extract the image when generating the html, but
> > instead have the image url point to a url for a cgi or mod-perl script
> > which extracts the image and prints it out to the browser...  For
> > example:
> 
> Thanks a lot for this suggestion. I never knew you could call a cgi as part
> of an IMG tag - I thought you had to link directly to a gif or jpg.
> 
> After testing I found you need to: print "Content-Type: image-gif\n\n"  then
> just write the gif to stdout.

IMNSHO this is definitely the 'B' answer.  The 'A' answer is to use
the temporary file because it is more cache-friendly.  You can, of
course, combine the approaches and have the IMG tag call a CGI which
creates the temporary file if it does not already exist and then
issues a redirect to the created file.

There may also be an 'A+' answer that is the same as the 'B' answer
but with suitable Etag and Last-Modified headers so that you can avoid
temporary files without screwing the HTTP caching mechanism.

None of this, of course, has anything whatever to do with Perl.


------------------------------

Date: Mon, 19 Nov 2001 09:22:37 +0000
From: Dave Barter <spam@phased.co.uk>
Subject: Re: Which ISPs support perl scripts?
Message-Id: <Af4K7.10494$tm3.1383920@news11-gui.server.ntli.net>

Chris

I think you are UK based

http://www.uklinux.net is the ISP you are after to learn CGI they also use 
profits to support open source, so ditch that freeserve account now !

Dave

Chris Clarke wrote:

> As an absolute perl beginner... how do I find an ISP which supports perl
> scripts?  I am currently with Freeserve, and the ISP would have to be
> free.
> I tried a search with Ask Jeeves for ISPs, to no avail.  I know you guys
> are WAY ahead of me technical-wise, but I've done some programming, and
> would like to learn perl. Freeserve doesn't have the facility for CGI or
> perl
> scripts.  Are there any (free) ISPs that you know of who do?
> 
> TIA,
> 
> Chris.
> 
> 




------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 2155
***************************************


home help back first fref pref prev next nref lref last post