[9163] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2781 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 1 18:07:24 1998

Date: Mon, 1 Jun 98 15:00:23 -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           Mon, 1 Jun 1998     Volume: 8 Number: 2781

Today's topics:
    Re: A Email to WWW GaTeWaY, is there such a Thing? (Tim Roberts)
    Re: Can't read c:\data <bluecoder@rocketmail.com>
        HELP ME PLEASE! <elopez@wpo.iupui.edu>
    Re: Help with Error message (Larry Rosler)
    Re: How to Get Index if given a value in the array??? (Tad McClellan)
    Re: LABOR CRISIS: Perl SW Guru NEEDED MA Intranet Start <jdporter@min.net>
        More Perlish file size (bytes, KB, MB) <choleman@simpact.com>
    Re: new to OO Perl (Larry Rosler)
        Perl Search Engine <bskirvin@wpo.iupui.edu>
        Please Help: How do you make a vote/polling script??? <matt@att.net>
    Re: Please Help: How do you make a vote/polling script? <probavm@cat.com>
    Re: Random permutations in Perl <wsetzer@babylon5.unity.ncsu.edu>
        require vs. use when, where, why, what... (Mike Shannon)
    Re: seek advice on simple first program <jdporter@min.net>
    Re: seek advice on simple first program <jdporter@min.net>
    Re: seek advice on simple first program <jdporter@min.net>
    Re: seek advice on simple first program <jdporter@min.net>
    Re: Statistics for comp.lang.perl.misc (Greg Lindahl)
        Truly bizarre bug: perl5.004_04/IO::Select/libwww-perl- <romansz@sequent.com>
    Re: Why is `undef' a unary op and not a list op? <rootbeer@teleport.com>
    Re: Why is `undef' a unary op and not a list op? <jdporter@min.net>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Mon, 01 Jun 1998 21:36:12 GMT
From: timr@probo.com (Tim Roberts)
Subject: Re: A Email to WWW GaTeWaY, is there such a Thing?
Message-Id: <35741de3.362727078@news.teleport.com>

f95pegr@granis.hemmet.s-hem.chalmers.se (Peter Granroth) wrote:

>on Wed, 27 May 1998 21:21:08 -0500, Igor shared with us the following words of wisdom:
>> If you know where I can find email-to-www gateway (a-la Hotmail) so that
>> I could read email from my Web Browser via HTTP, please email me.
>
>> Thanks.
>
>May I ask, why would you like to do that????

I'll give you a scenario.  My primary mail server is at my own office.
However, I do a fair amount of work at client locations, where they have
firewalls of various kinds.

There are several ways I can read my mail from the client's location.  I
can telnet into our server and run the Linux mail command; however, for
some reason, access through the telnet proxy servers appears to be in
permanent molasses mode.  I often have a one MINUTE delay for a command to
respond.  Plus, the Linux mail we use doesn't have a "more" option, so I
can only see the last 50 lines of each message.  However, the http proxy is
quite responsive.

So, I telnet in, fire off the MHonArc package which converts my mail file
to html pages, logout, and pop up a web browser to actually read the mail.
Much nicer.

- Tim Roberts, timr@probo.com
  Providenza & Boekelheide, Inc.


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

Date: Mon, 01 Jun 1998 21:23:15 GMT
From: BlueCoder <bluecoder@rocketmail.com>
To: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Can't read c:\data
Message-Id: <6kv643$2jl$1@nnrp1.dejanews.com>


> Does the script work from the command line ? If it does (and perhaps
> even if it doesnt) this is not a perl problem but you need to check
> the permissions on your directory - specifically that your
> IUSR_<WHATEVER> user has permission to read it.

The script did indeed work from the command line.

THANK YOU so much. The permissions for the c:\data directory
were set only for me. That is what was wrong.

> Whilst it might seem a bit much for a trivial (and I mean that in the
> best possible taste) script like this, you might want to consider
> using CGI.pm as it will make life a little easier when you start with
> some larger scripts (although there has been a little discussion here
> about its size recently.).

I do use cgi.pm and other libraries. My cgi.pm is actually custom
edited. While I could have used the standard I decided to remove it
from the script and present a simplified example which is easiest to
test and debug.

> Also you really should always check the success of your opendir .
> Infact it is just possible that if you had done something like:
>
> use CGI;
> use CGI::Carp qw(fatalsToBrowser);
>
> # This bit left as an exercise to reader
>
> opendir(DIR, "c:/data")  || die "Cant open directory - $! ";
>
> # etc
>
> you may have got some diagnostic information which would have answered
> your question.

Thank you again. This did not occur to me.


BlueCoder
bluecoder@rocketmail.com
May you live as long as you wish and love as long as you live.

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Mon, 01 Jun 1998 16:09:34 -0500
From: Elopez <elopez@wpo.iupui.edu>
Subject: HELP ME PLEASE!
Message-Id: <3573188E.F48B2637@wpo.iupui.edu>

<HTML>
Hi there.

<P>I am using a search engine using PERL.&nbsp; I am not a PERL programer
so I am using a basic search engine written by another programmer.&nbsp;
I am using the script to search the HTML files on my web site.&nbsp; The
script searches in the directory that I specify and opens all the HTML
files and compares the string used on the search form.&nbsp; Then it returns
a page with the links to those files.

<P><B>The problem:</B> Since I am using frames, the results of the search
returns all the left, top, and body parts of the frames as well as the
regular html files.

<P><B>My question is this:</B> What could I write/Include to the script
so it can avoid including on the search resutls the HTML pages that are
named as ("left_pagename.html" or "header_pagename.html" , and "body_pagename.html"?

<P>Please help me with this, I don't know any PERL.

<P>You can post your answer here or if you could, please send me an e-mail
message at:
<BR>elopez@wpo.iupui.edu
<BR>&nbsp;

<P><B>Thanks at lease for stopping by and reading my message!</B></HTML>



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

Date: Mon, 1 Jun 1998 14:44:25 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Help with Error message
Message-Id: <MPG.fdcc091d707ddfc989682@hplntx.hpl.hp.com>

In article <3572F21A.41C6@sierratel.com>, mattge@sierratel.com says...
> Im trying to learn perl and do not understand the following error
> message. After getting this message the program still runs and seems to
> work.	
> 
> value of <HANDLE> construct can be "0"; test with defined() at ./test.pl
> line 65535
> 
> Can someone tell me what this error message means?
> 
> Matt
> 

What it means is that your test -- which you didn't show, but must read 
something like

while ($line = <HANDLE>) { ... }

would return FALSE instead of TRUE if the file ended in a single zero 
without a final newline.  Picky, but true.  To suppress the warning, say

while (defined($line = <HANDLE>)) { ... }

because 0, though FALSE, *is* defined.

For historical reasons, the warning doesn't appear if the implicit 
assignment to $_ is used:

while (<HANDLE>) { .. }

Some members of this newsgroup believe it shouldn't appear in your 
situation either.  But it does.

-- 
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com


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

Date: Mon, 1 Jun 1998 15:55:44 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: How to Get Index if given a value in the array???
Message-Id: <gg4vk6.pmf.ln@localhost>

Todd A. Guillory (tag@io.com) wrote:
: I want to get the index if I'm given a value that occurs in an array (the
: opposite of the way it normally occurs).

: Is there a quicker way to  do this in PERL than what I have below?


You can just make a parallel hash with the string as the key, and its
index as the value.


: For example, if the $input{'month'} is "April" I have to use a for loop to
: find that is index value 3.  Is there a "PERL" way to do this?

: @months = ("January","February","March","April","May","June","July","August","September","October","November","December");


   for ($i=0; $i<@months; $i++) {
      $months{$months[$i]} = $i;
   }


: for ($index=0; $index <= (@months - 1); $index++ )  
:    {
:     if ( $months[$index] eq $input{'month'} )
:       {
:       $monthnumber = $index + 1;
:       } # end if
:     } # end for
:   }


Then, whenever you need the index, you can:

   print "the index of '$input{month}' is $months{$input{month}}\n";


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Mon, 01 Jun 1998 20:56:58 GMT
From: John Porter <jdporter@min.net>
Subject: Re: LABOR CRISIS: Perl SW Guru NEEDED MA Intranet Start-up 80K+>+Equity
Message-Id: <3573174E.1EBA@min.net>

Eric Bohlman wrote:
> 
> Ronald J Kimball <rjk@coos.dartmouth.edu> wrote:
> : John Chambers <jc@ral1.zko.dec.com> wrote:
> : > a much more credible explanation is that the employers are making up fake
> : > requirements and fake shortages as a technique of keeping pay scales low.
> 
> : Wouldn't a labor shortage result in higher pay scales?
> : high demand and low supply equals high prices
> 
> If the supply remains low, certainly.  But the alleged software labor
> shortage is usually invoked to justify
> 1) Relaxation of restrictions on hiring foreign nationals
> and
> 2) Increasing the number of CS graduates
> Both of which would increase the supply of programmers who would be
> willing to work for a low cost to the employer.  

But the whole point is why (and how) employers are justifying keeping
wages low.  If I were an employer, and that were my objective, I
would be saying, "Sorry, I won't pay programmers any more than this, 
because there's a glut of programmers."  But they're saying the
opposite,
so therefore that's not their objective.  Employers always pay the
minimum that they can (generally); if pay rates seem flat, it's
because workers are willing to work for that. OTOH, pay rates for
programmers don't seem particularly flat to me.

It may be that the shortage is being exaggerated for political
purposes, such as those you mentioned; but even if so, those
purposes are still unrealized, so pay rates will not yet have
been affected by surging numbers of programmers from colleges
and foreign countries.

John Porter


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

Date: Mon, 1 Jun 1998 14:07:19 -0700
From: "C.W.Holeman II" <choleman@simpact.com>
Subject: More Perlish file size (bytes, KB, MB)
Message-Id: <6kv4q7$qup@newshub.atmnet.net>

This works but how about something more Perlish?

    my $s = -s "$MP1001__PARTS_DIR/HT-201/$_.html";
    if ($s < 500)
        {$thesize = "$s bytes";}
    elsif ($s < 500000)
        {$thesize = ($s/1000)." KB";}
    else
        {$thesize = ($s/1000000)." MB";}

--
C.W.Holeman II                                              (619)503-1101
Configuration Management Specialist
Simpact Associates Inc.
choleman@simpact.com




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

Date: Mon, 1 Jun 1998 14:32:14 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: new to OO Perl
Message-Id: <MPG.fdcbdb8c215d47e989681@hplntx.hpl.hp.com>

In article <896729059.261142@thrush.omix.com>, zenin@bawdycaste.org 
says...
> John Porter <jdporter@min.net> wrote:
> 	>snip<
> : Arrays seem to be a bit faster than hashes, so if one can
> : reasonably implement his objects as blessed array-refs
> : rather than hash-refs, it should be faster. I've seen it done.
> 	>snip<
<snip>
>     Speed
>         Using an array ref for an object yields much faster access times
>         then a hash ref. Because the symbolic constants this module defines
>         will be inlined by the perl interpreter there is no run time over
>         head for name look up.
<snip>

I put together a rudimentary Benchmark to quantize some of these 
assertions.  Because my scripts *have to* run in some environments that 
provide only obsolete versions of perl, I simulated constant.pm and ran 
the benchmark twice: on perl 5.002 (which does not inline constants) and 
perl 5.004 (which does).  Compared to real code, the results unnaturally 
isolate access times to members of aggregates, but are dramatic.  I 
hesitate to say YMMV, because relatively speaking it probably won't.

#!/usr/local/bin/perl -w
use Benchmark;

@array = 0 .. 9;
%hash = ( NAME => 8 );
*EIGHT = sub () { 8 };
$eight = 8;

timethese (1 << 18, {
    array    => q{ $x = $array[8] },
    constant => q{ $x = $array[EIGHT] },
    variable => q{ $x = $array[$eight] },
    hash     => q{ $x = $hash{NAME} },
} );
__END__

Benchmark: timing 262144 iterations of array, constant, hash, variable...
     array:  2 secs ( 0.97 usr  0.00 sys =  0.97 cpu)
  constant:  6 secs ( 5.29 usr  0.00 sys =  5.29 cpu)
      hash:  2 secs ( 2.01 usr  0.00 sys =  2.01 cpu)
  variable:  1 secs ( 1.68 usr  0.00 sys =  1.68 cpu)

Benchmark: timing 262144 iterations of array, constant, hash, variable...
     array:  1 secs ( 1.01 usr  0.01 sys =  1.02 cpu)
  constant:  2 secs ( 1.00 usr  0.02 sys =  1.02 cpu)
      hash:  2 secs ( 1.95 usr  0.03 sys =  1.98 cpu)
  variable:  2 secs ( 1.72 usr  0.02 sys =  1.74 cpu)

-- 
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com


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

Date: Mon, 01 Jun 1998 15:59:22 -0500
From: Brandy Skirvin <bskirvin@wpo.iupui.edu>
Subject: Perl Search Engine
Message-Id: <3573162A.92BF7855@wpo.iupui.edu>


--------------B162EACCA346ECA9DC0F7B6E
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi there.

I am using a search engine using PERL.  I am not a PERL programer so I
am using a basic search engine written by another programmer.  I am
using the script to search the HTML files on my web site.  The script
searches in the directory that I specify and opens all the HTML files
and compares the string used on the search form.  Then it returns a page
with the links to those files.

The problem: Since I am using frames, the results of the search returns
all the left, top, and body parts of the frames as well as the regular
html files.

My question is this: What could I write/Include to the script so it can
avoid including on the search resutls the HTML pages that are named as
("left_pagename.html" or "header_pagename.html" , and
"body_pagename.html"?

Please help me with this, I don't know any PERL.

You can post your answer here or you could send me an e-mail message at:

elopez@wpo.iupui.edu


Thanks at lease for stopping by and reading my message!

--------------B162EACCA346ECA9DC0F7B6E
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<HTML>
Hi there.

<P>I am using a search engine using PERL.&nbsp; I am not a PERL programer
so I am using a basic search engine written by another programmer.&nbsp;
I am using the script to search the HTML files on my web site.&nbsp; The
script searches in the directory that I specify and opens all the HTML
files and compares the string used on the search form.&nbsp; Then it returns
a page with the links to those files.

<P><B>The problem:</B> Since I am using frames, the results of the search
returns all the left, top, and body parts of the frames as well as the
regular html files.

<P><B>My question is this:</B> What could I write/Include to the script
so it can avoid including on the search resutls the HTML pages that are
named as ("left_pagename.html" or "header_pagename.html" , and "body_pagename.html"?

<P>Please help me with this, I don't know any PERL.

<P>You can post your answer here or you could send me an e-mail message
at:
<BR>elopez@wpo.iupui.edu
<BR>&nbsp;

<P><B>Thanks at lease for stopping by and reading my message!</B></HTML>

--------------B162EACCA346ECA9DC0F7B6E--



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

Date: Mon, 01 Jun 1998 16:53:55 -0400
From: "Matt L." <matt@att.net>
Subject: Please Help: How do you make a vote/polling script???
Message-Id: <6kv487$sop@bgtnsc03.worldnet.att.net>

All,

I really want to add a "vote.cgi" script to my website so that I can
include questions on my home page and have people vote on them by
clicking on a radio button listed next to one of the choices.

I want it to look and work like the espn (http://espnet.sportszone.com)
vote script works.  After the user clicks the "submit" button, it should
tally the results and bring the user to a duplicate home page which
posts the poll results where the question use to be.

How can I do this?

Can you point me to some instruction on how to tally results in PERL?

I really really appreciate any help you can give me on writing this
script in PERL

Please advise.

Thanks a lot,

Matt
sabu@att.net


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

Date: Mon, 01 Jun 1998 16:27:15 -0500
From: "Vincent M. Probasco" <probavm@cat.com>
Subject: Re: Please Help: How do you make a vote/polling script???
Message-Id: <35731CB3.F23936CC@cat.com>

Matt,
    I asume you know some PERL. You'll need to have a file seperate from
your cgi script that keeps
track of the voting results. The file might start out looking like
this...

0
0
0
0


        Each zero would be a different field that you want to keep track
of. You can then parse this data
and add to it as necesary. I know this is brief , but I hope it helps.
You'll need to use the open() and
close() functions to get to the data inside the file.





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

Date: 01 Jun 1998 17:18:16 -0400
From: William P Setzer <wsetzer@babylon5.unity.ncsu.edu>
Subject: Re: Random permutations in Perl
Message-Id: <lzyu364vn1j.fsf@babylon5.unity.ncsu.edu>

mjd@op.net (Mark-Jason Dominus) writes:
: In article <6ksbt4$kmt@mozo.cc.purdue.edu>,
: Hisao Nakanishi <hisao@physics.purdue.edu> wrote:
: >
: >Is there a simple way to generate permutations of n numbers
: >(say, 1,2, thru n) randomly (keyed by some seed number) in
: >Perl?  Is there a module that does this already available?
: 
: The function `n2perm' below accepts two numbers, N and S.  It then
: generates the Nth permutations of the integers 0 ... S-1 in the
: lexicographic ordering.  If you select N at random from [0 .. S!-1],
: you get a random permutation.

Interesting stuff.  This one relies on the "goodness" of the random
generator perhaps more than it should, but eliminates that factorial
call.  It pretty much does the standard "pick a number out of the hat
randomly" method.  It's not as efficient as it could be, but there's
something to be said for aesthetics. :)

   # N is permutation size, S is seed.
   #
   sub perm {
      my $N    = shift;
      my $S    = shift;
      my @perm = 1..$N;

      srand $S;
      while ($N) {
         my $P = int rand $N--;

         @perm[$N, $P] = @perm[$P, $N];
      }
      @perm;
   }


William


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

Date: Mon, 01 Jun 1998 21:49:34 GMT
From: mshannon@lds.com (Mike Shannon)
Subject: require vs. use when, where, why, what...
Message-Id: <OlFc1.761$_i.1590689852@newsreader.digex.net>

Hi,

Can anyone tell me what the difference is between use and require;
when I should use one or the other; does use use @INC, and anything
else a novice perl developer should need to know about them?

Thanks...Mike
mshannon@lds.com



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

Date: Mon, 01 Jun 1998 21:16:27 GMT
From: John Porter <jdporter@min.net>
Subject: Re: seek advice on simple first program
Message-Id: <35731BDE.45A8@min.net>

Shaun Sides wrote:
> 
> Yay.  I've managed to actually write a useful little program in Perl.
> ;-)  All it does is doublespace a file.  I have a couple of ideas for
> some other simple things I can try my hand at, too.  So, what I'd like
> to know is just how inefficient my algorithm is, brief advice on same,
> and that sort of thing.  Hell, if someone wants to show me a totally
> obfuscated version of it, go ahead! ;-)  I'm sure I'd learn something
> from it.
> 
> #!/usr/bin/perl -w
> # ds.pl --> Double-space
> # Program to take single spaced text files and add an
> # extra \n to the end of each line.
> # usage: ds <filename1> <filename1> <...> <filenamen>

Well, if you don't mind changing the "usage":

% perl -pi.bak -e 's/$/\n/'  file1 file2 filen

I.e., by using the right command line switches, you can
put your entire program onto the command line.  In fact,
the program in this case is a 7-character string:

	s/$/\n/

which appends a \n to each line.

hth,
John Porter


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

Date: Mon, 01 Jun 1998 21:21:04 GMT
From: John Porter <jdporter@min.net>
Subject: Re: seek advice on simple first program
Message-Id: <35731CF3.7EEC@min.net>

Ronald J Kimball wrote:
> 
> perl -pi -e 'print "$_\n"'

No, this isn't quite right -- it prints each line twice:
once for the -p and once for the print stmt.

John Porter


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

Date: Mon, 01 Jun 1998 21:37:41 GMT
From: John Porter <jdporter@min.net>
Subject: Re: seek advice on simple first program
Message-Id: <357320D8.59AA@min.net>

Larry Rosler wrote:
> 
> That's neat, and suggests Yet Another Way to Do It, using $\, the output
> record separator:
> 
> $\ = "\n";
> ...
>    print F @content;
> ...

Which leads to:

% perl -pi -e 'BEGIN{$\="\n"}'  filename

John Porter


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

Date: Mon, 01 Jun 1998 21:43:32 GMT
From: John Porter <jdporter@min.net>
Subject: Re: seek advice on simple first program
Message-Id: <35732237.43C0@min.net>

Shaun Sides wrote:
> 
> # Program to take single spaced text files and add an
> # extra \n to the end of each line.

Here's another way.  Read the entire file in as one string,
then replace all newlines with double-newlines:

% perl -0777 -pi -e 's/\n/\n\n/g'  file1 file2 filen

John Porter


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

Date: 1 Jun 1998 19:48:47 GMT
From: lindahl@pbm.com (Greg Lindahl)
Subject: Re: Statistics for comp.lang.perl.misc
Message-Id: <6kv0iv$5bb@news1.newsguy.com>

gbacon@cs.uah.edu (Greg Bacon) writes:

> Senseless?  It seems to me that when someone has worked very hard to
> produce a gift for the community the worst response is to say that it
> wasn't really a gift.

Nobody says that a wonderful gift is going to meet everyone's
needs. This shouldn't bother Tom one bit.

-- g


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

Date: Mon, 01 Jun 1998 14:28:38 -0700
From: Zach Romans <romansz@sequent.com>
Subject: Truly bizarre bug: perl5.004_04/IO::Select/libwww-perl-5.32
Message-Id: <35731D06.753D1403@sequent.com>

Greetings, all.  I've looked through all the resources I know of, and
have been unable to find a solution to this problem.  I apologize in
advance for the length and verbosity of this message, and the wide
audience I'm addressing, but I want to include as much information as
possible from the outset in hopes that somebody, somewhere, will read
this and spring forth with "I have the magic voodoo cookie you 
seek!!!".  :^)

I'm using 5.004_04, under DYNIX/ptx 4.4.2.  I built this myself, and
with some moderate effort (manually telling config.sh that ptx does
indeed have usable BSD sockets, and adding -lc so that the POSIX shared
object was "sane"), all of the distribution's built-in tests passed with
flying colors.  Output of perl -V following my problem description.

libwww-perl-5.32 is what has revealed this problem, but it "smells" like 
it might be coming from somewhere deeper.  Throughout this exercise,
I've jumped to numerous conclusions as to where the root of the problem
was, but I won't make any blind guesses here, as I've determined that
whatever it is is quite thoroughly out of my realm of expertise.  :^)

After getting and installing HTML-Parser-2.17 and MIME-Base64-2.05, I
do the make of libwww-perl.  During 'make test', the net/http-timeout
and net/moved tests both fail (everything else succeeds).  Running the
TEST script with the -v flag on these tests reveals a "500 (Internal
Server Error) write timeout" as the cause (this is after enabling trace,
debug, and conns output to LWP via the LWP::Debug::level() method);

----
{romansz} eng4:~/build/PerlModules/libwww-perl-5.32/t
507 > ./TEST -v net/moved.t
net/moved...........LWP::UserAgent::new: ()
LWP::UserAgent::request: ()
LWP::UserAgent::simple_request: GET
http://eng4.sequent.com/cgi-bin/lwp/moved
LWP::UserAgent::_need_proxy: (http://eng4.sequent.com/cgi-bin/lwp/moved)
LWP::UserAgent::_need_proxy: Not proxied
LWP::Protocol::http::request: ()
LWP::UserAgent::request: Simple result: Internal Server Error
1..1
GET http://eng4.sequent.com/cgi-bin/lwp/moved

500 (Internal Server Error) write timeout
Client-Date: Mon, 01 Jun 1998 20:01:41 GMT

[further test failure notices nuked to emulate brevity]
----

After digging through the test code, a good portion of the module
itself, and the httpd logs, the program is never acutally contacting the
server, which makes the "Internal Server Error" message bogus, but
that's a different issue.  

There is an un-documented method in LWP::UserAgent called "use_eval",
which, if set to false, causes this spurious error message to disappear,
and helps the module that is barfing to reveal itself;

----
{romansz} eng4:~/build/PerlModules/libwww-perl-5.32/t
508 > ./TEST -v net/moved.t
net/moved...........LWP::UserAgent::new: ()
LWP::UserAgent::request: ()
LWP::UserAgent::simple_request: GET
http://eng4.sequent.com/cgi-bin/lwp/moved
LWP::UserAgent::_need_proxy: (http://eng4.sequent.com/cgi-bin/lwp/moved)
LWP::UserAgent::_need_proxy: Not proxied
LWP::Protocol::http::request: ()
write timeout at ../blib/lib/LWP/Protocol/http.pm line 136.
1..1
GET http://eng4.sequent.com/cgi-bin/lwp/moved

----

LWP::Protocol::http is the module that is choking.  Specifically, it is
the request method.  This "does its thing", checking the validity of the 
request method, checks if we're proxying, and creates and "checks" the
socket connection to the desired host (the check is a lie, because the
_check_sock method is a no-op).  It then uses the IO::Select module to
create its $sel object;

my $sel = IO::Select->new($socket) if $timeout;

Then it goes on and does more http-specific foo, building up the headers
for the request, generating the initial buffer to send, etc...

Finally, we get down to business, and the code that is generating this 
"write timeout" (this isn't a conditional block - the curlies are there
for the benefit of the my);

{
   die "write timeout" if $timeout && !$sel->can_write($timeout);
   my $n = $socket->syswrite($buf, length($buf));
   die $! unless defined($n);
   die "short write" unless $n == length($buf);
   LWP::Debug::conns($buf);
}

The first die() is the one causing the error.  By using the
LWP::Debug::debug method, I've been able to determine that
$sel->can_write($timeout) is returning undef.  This is the same $sel
object created by the above IO::Select->new() call.  I added the
following LWP::Debug::debug calls immediately before the problematic
die() call;

   LWP::Debug::debug("\$timeout is " . $timeout . "\n");
   LWP::Debug::debug("\$sel->can_write(\$timeout) is \"" . 
                     $sel->can_write($timeout) . "\"\n");

With both of these lines in-place, THE TEST SCRIPT WORKS;

----
{romansz} eng4:~/build/PerlModules/libwww-perl-5.32/t
509 > ./TEST -v net/moved.t
net/moved...........LWP::UserAgent::new: ()
LWP::UserAgent::request: ()
LWP::UserAgent::simple_request: GET
http://eng4.sequent.com/cgi-bin/lwp/moved
LWP::UserAgent::_need_proxy: (http://eng4.sequent.com/cgi-bin/lwp/moved)
LWP::UserAgent::_need_proxy: Not proxied
LWP::Protocol::http::request: ()
LWP::Protocol::http::request: $timeout is 180
LWP::Protocol::http::request: $sel->can_write($timeout) is "1"
LWP::Protocol::http::request: GET /cgi-bin/lwp/moved HTTP/1.0

[further output suppressed]
----

If I comment out the first line of the debug code (the "\$timeout is"... 
line), the test once again fails, and;

1) perl generates an "uninitialized value" warning for the debug line,
   appearing on STDOUT immediately prior to the output from the debug() 
   call.
2) The second debug line outputs;
LWP::Protocol::http::request: $sel->can_write($timeout) is "" 
[i.e. undef]

If I uncomment the first line, these problems go away (and there is no
uninitialized value warning), and the test script works.

Additionally;

*) If I comment out the second debug() call, leaving the first in place,
   the test completes successfully.

*) It does not matter if debug-level output is turned on via the 
   LWP::Debug::level method in the net/moved.t code.
   (i.e. if the "\$timeout is" ... line is present in the http.pm code 
   itself, the script works.  If it's not, it doesn't.)

*) Adding the code;

LWP::Debug::debug($timeout);

   in place of the other two debug() calls does not fix the undef
value       from the can_write call.  However,

LWP::Debug::debug("" . $timeout);

   does (i.e. the script works).  But it gets wierder; one, two, or   
three characters (anything printable, including \t tab characters) in   
the quotes causes the die to happen.  Four or more, and the script   
works.

*) Using print() directly, in place of LWP::Debug::debug(), has the   
exact same effects.

*) Neither the can_write or can_read methods of IO::Select seem to be 
   blocking for the timeout period specified by the $timeout value (both
   calls return undef immediately).  The has_error method does appear
to    be blocking, but still returns undef.   I have verified that
select()    itself is functional (i.e. select(undef,undef,undef,10)
blocks for 10    seconds and then returns).  

   In an earlier build of perl itself, this was not the case (i.e. the 
   latter select call returned immediately), but rebuilding using vfork 
   and the perl-provided malloc fixed it.

So, with all that said, anybody got any ideas?  I think I can safely say 
that this is by far the weirdest, not to mention most disconcerting,
thing that I have ever encountered in the past five years that I have
been working with perl on an almost daily basis.

Any and all advice, suggestions, and moral support greatly
appreciated...

aTdHvAaNnKcSe

Zach Romans - romansz@sequent.com

========
perl -V output;

Summary of my perl5 (5.0 patchlevel 4 subversion 4) configuration:
  Platform:
    osname=dynixptx, osvers=4.4.2, archname=i386-dynixptx
    uname='dynixptx eng4 4.0 v4.4.2 i386 '
    hint=previous, useposix=true, d_sigaction=define
    bincompat3=n useperlio=undef d_sfio=undef
  Compiler:
    cc='cc', optimize='-O', gccversion=
    cppflags=''
    ccflags =''
    stdchar='unsigned char', d_stdstdio=define, usevfork=true
    voidflags=15, castflags=0, d_casti32=define, d_castneg=define
    intsize=4, alignbytes=4, usemymalloc=y, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lsocket -lnsl -ldl -lld -lm -lc -lcrypt -lPW
    libc=, so=so
    useshrplib=true, libperl=libperl.so
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=''
    cccdlflags='-KPIC', lddlflags='-G -L/usr/local/lib'

Characteristics of this binary (from libperl): 
  Built under dynixptx
  Compiled at May 28 1998 16:19:37
  @INC:
    /usr/local/perl/lib/i386-dynixptx/5.00404
    /usr/local/perl/lib
    /usr/local/perl/lib/site_perl/i386-dynixptx
    /usr/local/perl/lib/site_perl
    .

========


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

Date: Mon, 01 Jun 1998 20:49:15 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Why is `undef' a unary op and not a list op?
Message-Id: <Pine.GSO.3.96.980601132421.15370I-100000@user2.teleport.com>

On 1 Jun 1998, Mark-Jason Dominus wrote:

> I don't see any reason why 
> 
> 	undef @foo;
> 
> would necessarily evaluate @foo just because `undef' was now a list
> operator.  I'm asking a syntactic change; it needn't be accompanied by
> a semantic change.
> 
> Of course, such a change might be difficult to implement, but I
> haven't looked, so I don't know.

It would (almost certainly) be easy to implement. In fact, this was
brought up among the Perl developers a few months ago - with the comment
that it's probably too late to change it, as I recall. Perhaps it could be
changed, though. But since it currently gives a warning (when warnings are
requested) I don't worry about it causing problems in _my_ code. :-)

It's worth noting, though, that these two are equally problematic yet
functionally different: 

    undef @foo, @bar, @baz; 
    undef(@foo, @bar, @baz); 

And, even more exciting, one makes for a compile-time warning, while the
other does the warning at run time. Perl is pretty wild, huh? 

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Mon, 01 Jun 1998 21:49:16 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Why is `undef' a unary op and not a list op?
Message-Id: <3573238F.2CBE@min.net>

Mark-Jason Dominus wrote:
> 
> But at present, we have the situation that the argument of `undef' is
> in a special context: it's not evaluated.
>...
> I don't see any reason why
> 
>         undef @foo;
> 
> would necessarily evaluate @foo just because `undef' was now a list
> operator.  I'm asking a syntactic change; it needn't be accompanied by
> a semantic change.

Yes; I think 

	undef( $a, @b, %c );

would have exactly the same semantics as

	local( $a, @b, %c );

 ...except for localizing the value.

John Porter


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

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 2781
**************************************

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