[13461] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 871 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Sep 21 22:07:18 1999

Date: Tue, 21 Sep 1999 19:05:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <937965907-v9-i871@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 21 Sep 1999     Volume: 9 Number: 871

Today's topics:
        "Pattern matching" <mereddy@idt.net>
    Re: "Pattern matching" <bwalton@rochester.rr.com>
    Re: a simple redirect with bells and whistles <makkulka@cisco.com>
    Re: a simple redirect with bells and whistles <makkulka@cisco.com>
    Re: Ad hominem (was Re: perl related question now!) (Larry Rosler)
    Re: answers (Larry Rosler)
    Re: Getting results from system command (Martien Verbruggen)
    Re: I could use perldoc perlipctut (Martien Verbruggen)
    Re: I could use perldoc perlipctut (Kragen Sitaker)
    Re: I could use perldoc perlipctut (Martien Verbruggen)
    Re: I could use perldoc perlipctut (Kragen Sitaker)
        Interesting behavior of IO::Handle - bug? <brundlefly76@hotmail.com>
    Re: Interesting behavior of IO::Handle - bug? (Kragen Sitaker)
    Re: mkdir(). What am I doing wrong? (Peter McMorran)
    Re: Preserving file name of uploaded file <makkulka@cisco.com>
    Re: Preserving file name of uploaded file <dove@synopsys.com>
        Problem doing authentication with Apache::DBI <2bunnyhop@home.com>
    Re: Problem with method - unblessed (Martien Verbruggen)
    Re: Some e-mails get sent, some don't (Martien Verbruggen)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Tue, 21 Sep 1999 18:50:10 -0600
From: Anil Mereddy <mereddy@idt.net>
Subject: "Pattern matching"
Message-Id: <37E827C1.90767D55@idt.net>

Hello all,

I am attemting to write a perl program that will read one or more files
and analyze the contents of the files.
I was trying to find out capitalized words, puntuation marks, blank
lines, # of sentences in the file.

I started of with the following code and I am getting no where..

while ( <> ) {

   $test = $_;

   while ($test =~ /\S+/) {
      ++word_count;
   }
}

I am certain that I am doing it wrong. Any help to resolve this will be
greatly appreciated.

Thanks








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

Date: Tue, 21 Sep 1999 21:57:41 -0400
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: "Pattern matching"
Message-Id: <37E83795.8F935C54@rochester.rr.com>

Anil Mereddy wrote:
> 
> Hello all,
> 
> I am attemting to write a perl program that will read one or more files
> and analyze the contents of the files.
> I was trying to find out capitalized words, puntuation marks, blank
> lines, # of sentences in the file.
> 
> I started of with the following code and I am getting no where..

Anil, you have several problems:

> 
> while ( <> ) {
> 
>    $test = $_;
> 
>    while ($test =~ /\S+/) {
The above defines an infinite loop.  To get the interative behavior
you are after, add the "g" switch to the pattern match, as in:

while($test=~/\S+/g){

>       ++word_count;
The above won't compile.  You are missing the $ in front of the
variable name.  Should be:

++$word_count;

>    }
> }
You didn't print out $word_count, so you won't know if it worked
or not.  Also, realize that you are counting runs of non-white-space
characters, which isn't necessarily quite the same as counting words,
depending, perhaps, on what you mean by words.
> 
> I am certain that I am doing it wrong. Any help to resolve this will be
> greatly appreciated.
> 
> Thanks
-- 
Bob Walton


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

Date: Tue, 21 Sep 1999 17:06:50 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: a simple redirect with bells and whistles
Message-Id: <37E81D99.5595D7CD@cisco.com>

[ Jamil Aslam wrote:

> I forgot to mention that although I could print the response, the URI of the
> browser would obviously not point to the right place and instead at the original
> script. I'm trying to make the whole operation invisible to the end user. i think.

Ok. Now I understand. You want to call cgi1 using your browser but
cgi1 is gonna call cgi2 (transperantly ) and then you want the browser
to show results to cgi2 ( after cgi1 posts input to cgi1 ).  After this
is done the URL in the browser should reflect call for cgi2 and NOT cgi1.

There is only one way to do this  ( as far as I know and that
is using javascript ). The problem of manipulating the location
object is that once you assign a new url to location.href then
the browser tries to reload this particular page if availablke
which is something that we do not want.

Hence use the following workaround --

Let cgi1 call cgi2 and collect results and then
store then to a temporary file (instead of sending
the cgi2 o/p to browser). Let cgi2 redirect browser
with a URL that makes the browser load from
the temporary file we have created.
--



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

Date: Tue, 21 Sep 1999 17:21:23 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: a simple redirect with bells and whistles
Message-Id: <37E82103.ABD2E48A@cisco.com>

[  Makarand Kulkarni wrote:

>
> Let cgi1 call cgi2 and collect results and then
> store then to a temporary file (instead of sending
> the cgi2 o/p to browser). Let cgi2 redirect browser
> with a URL that makes the browser load from
> the temporary file we have created.
> --

I wrongly said that cgi2 should do the redirect.
Actually cgi1 should redirect the browser after
calling cgi2 is complete.

whew !!

--





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

Date: Tue, 21 Sep 1999 18:06:55 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Ad hominem (was Re: perl related question now!)
Message-Id: <MPG.1251cb88a27393df989fb8@nntp.hpl.hp.com>

In article <37E80141.9A05EBBC@chaos.wustl.edu> on Tue, 21 Sep 1999 
18:07:32 -0400, Elaine -HFB- Ashton <elaine@chaos.wustl.edu> says...
 ...
> Sember ubi, sub ubi. :)

Semper???  But good advice, in any case.   At least, that's what my 
mother would say.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Tue, 21 Sep 1999 18:12:38 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: answers
Message-Id: <MPG.1251cce4af6e9474989fb9@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <37e80636@cs.colorado.edu> on 21 Sep 1999 16:27:02 -0700, Tom 
Christiansen <tchrist@mox.perl.com> says...
> In comp.lang.perl.misc, "Andrew" <casino@start.com.au> writes:
> :love the way people say...
> :'not a perl question'
> :or
> :'read some doco'
> :
> :is this because you are so arrogant or just don't know?
> 
> Anybody want to bet me this is a Prisoner of Bill?  Sure smells of it.

You are probably right.

X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2014.211
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211

Of course, that isn't definitive.  Even I am using Windows NT to post 
from.  But I have bought a decent newsreader.

PoB-ness is a state of mind, not of tools.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 22 Sep 1999 01:10:05 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Getting results from system command
Message-Id: <N%VF3.92$ml3.6410@nsw.nnrp.telstra.net>

In article <37edce0d.12239330@news.bcandid.deja.com>,
	root@127.0.0.127 (Sniper) writes:
> Ok after reading the FAQ, llama book and some of the Camel book, I am
> delurking for help, Help!

# perldoc -f system
[snip]
This is I<NOT> what you want to use to capture
the output from a command, for that you should use merely backticks or
C<qx//>, as described in L<perlop/"`STRING`">.
[snip]

Books are good. Using the documentation that comes with perl is better.

Order of looking things up:

- documentation that ships with perl
- FAQ that ships with perl
- books
- deja.com/other search engines
- documentation that ships with perl
- FAQ that ships with perl
- newsgroup
- documentation that shipd with perl 

:)

Seriously, you will do yourself a big, enormouns, gigantic favour by
learning how to use the doucmentation on your hard disk. And by
learning how to use something like deja.com for searching this
newsgroups archive

Martien
-- 
Martien Verbruggen                  | 
Interactive Media Division          | If it isn't broken, it doesn't have
Commercial Dynamics Pty. Ltd.       | enough features yet.
NSW, Australia                      | 


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

Date: Wed, 22 Sep 1999 00:17:11 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: I could use perldoc perlipctut
Message-Id: <beVF3.70$ml3.5445@nsw.nnrp.telstra.net>

In article <AMOE3.18513$N77.1387885@typ11.nn.bcandid.com>,
	kragen@dnaco.net (Kragen Sitaker) writes:

> It won't be any faster unless you're on MOSIX (www.mosix.cs.huji.ac.il)
> or an SMP.

\begin{offtopic}

[with multithreading I mean forking as well as 'lightweight' threads
(a value judgment which should be eradicated from the language)]

That is of course not true. If you have any blocking actions in your
program (reads from file systems, network accesses, DNS lookups to
name just a few), then parallellism can help tremendously in speeding
things up. If your program is not CPU bound, but I/O bound, then you
may see big increases. Especially if the I/O of the process uses more
than one device (NIC, multiple disks/controllers), you will see
speedups. Serialised, each access to the I/O subsystem would block the
whole chain of events. In parallell, one process may be blocked on one
I/O, while another is happily reading from  or writing to another I/O
system.

Anywhere where serialising access to a resource needs to be balanced
between all the various processes accessing the reource or service,
you need to multithread. Web servers and FTP servers are a good
example.

Why did you think that multithreading was such a big thing with the
majority of machines being single CPU boxes?

\end{offtopic}

Martien
-- 
Martien Verbruggen                  | 
Interactive Media Division          | The gene pool could use a little
Commercial Dynamics Pty. Ltd.       | chlorine.
NSW, Australia                      | 


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

Date: Wed, 22 Sep 1999 00:26:38 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: I could use perldoc perlipctut
Message-Id: <2nVF3.2281$QJ.88217@typ11.nn.bcandid.com>

In article <beVF3.70$ml3.5445@nsw.nnrp.telstra.net>,
Martien Verbruggen <mgjv@comdyn.com.au> wrote:
>In article <AMOE3.18513$N77.1387885@typ11.nn.bcandid.com>,
>	kragen@dnaco.net (Kragen Sitaker) writes:
>
>> It won't be any faster unless you're on MOSIX (www.mosix.cs.huji.ac.il)
>> or an SMP.
>
>\begin{offtopic}
>
>[with multithreading I mean forking as well as 'lightweight' threads
>(a value judgment which should be eradicated from the language)]
>
>That is of course not true. If you have any blocking actions in your
>program (reads from file systems, network accesses, DNS lookups to
>name just a few), then parallellism can help tremendously in speeding
>things up.

Of course you are correct; thank you for pointing this out.

>Anywhere where serialising access to a resource needs to be balanced
>between all the various processes accessing the reource or service,
>you need to multithread. Web servers and FTP servers are a good
>example.

I note that thttpd and Zeus do quite nicely as Web servers without
multithreading.  I'm not clear on what you mean by 'serialising access
to a resource needs to be balanced'.

>Why did you think that multithreading was such a big thing with the
>majority of machines being single CPU boxes?

Originally, I thought it was mostly to keep machines from having to
wait for people to decide what they wanted to do, and to keep people
from having to wait for machines to finish what they were doing before
the people started doing something else -- although some of my old OS
textbooks do say multitasking is good because it results in more
efficient CPU utilization.

But thanks for the clarification.  I sort of assumed, without warrant,
that the original poster was talking about a CPU-bound process.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Tue Sep 21 1999
48 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Wed, 22 Sep 1999 01:29:44 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: I could use perldoc perlipctut
Message-Id: <ciWF3.97$ml3.6410@nsw.nnrp.telstra.net>

In article <2nVF3.2281$QJ.88217@typ11.nn.bcandid.com>,
	kragen@dnaco.net (Kragen Sitaker) writes:
> In article <beVF3.70$ml3.5445@nsw.nnrp.telstra.net>,
> Martien Verbruggen <mgjv@comdyn.com.au> wrote:

>>Anywhere where serialising access to a resource needs to be balanced
>>between all the various processes accessing the reource or service,
>>you need to multithread. Web servers and FTP servers are a good
>>example.
> 
> I note that thttpd and Zeus do quite nicely as Web servers without
> multithreading.  I'm not clear on what you mean by 'serialising access
> to a resource needs to be balanced'.

Err.. I don't think I expressed that entierly as I should have.

I basically meant that if you have a resource somewhere, that only has
one portal for access (say an FTP server), you can't make each client
request a blocking request. It would be a bit silly for everyone to
have to wait for the transaction that comes before to finish.

If you need to treat multiple accesses to this resource from the
outside as 'equal', in other words, assign an equal amount of priority
to all of them, multithreading becomes the thing to do.

I don't know about Zeus and thttpd, and how they work. If they
serialise access to the service, then they may be fine for small
numbers of accesses, and small service times, but what happens if one
person is downloading a 3 MB file over a modem connection? Does the
next request get queued up until that's finished?

Martien
-- 
Martien Verbruggen                  | 
Interactive Media Division          | Think of the average person. Half of
Commercial Dynamics Pty. Ltd.       | the people out there are dumber.
NSW, Australia                      | 


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

Date: Wed, 22 Sep 1999 01:50:06 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: I could use perldoc perlipctut
Message-Id: <iBWF3.2398$QJ.100887@typ11.nn.bcandid.com>

In article <ciWF3.97$ml3.6410@nsw.nnrp.telstra.net>,
Martien Verbruggen <mgjv@comdyn.com.au> wrote:
>I basically meant that if you have a resource somewhere, that only has
>one portal for access (say an FTP server), you can't make each client
>request a blocking request. It would be a bit silly for everyone to
>have to wait for the transaction that comes before to finish.

Right, and multithreading is very handy for avoiding this.

>If you need to treat multiple accesses to this resource from the
>outside as 'equal', in other words, assign an equal amount of priority
>to all of them, multithreading becomes the thing to do.

Well, it certainly makes your life much easier.

>I don't know about Zeus and thttpd, and how they work. If they
>serialise access to the service, then they may be fine for small
>numbers of accesses, and small service times, but what happens if one
>person is downloading a 3 MB file over a modem connection? Does the
>next request get queued up until that's finished?

No; they sit in a select() loop.  Whenever a file descriptor that has
data waiting to be written becomes writable, they write to it.
Whenever a file descriptor becomes readable -- i.e. has data waiting to
be read -- they read it (or accept() on it, as the case may be).  I
understand IRC servers work the same way; they can't usefully fork into
one process per client.  I wrote a chat server that worked the same way
in Perl, although I think I have deleted it by now.  I have some
similar code in Perl for an IRC client; would you like me to post it?

So the 3 MB file gets sent in little pieces, and other clients are
serviced meanwhile.

Zeus is generally the fastest Web server for static files on a
single-CPU machine (excluding, of course, khttpd).  thttpd is fast
too.

-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Tue Sep 21 1999
48 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Wed, 22 Sep 1999 00:33:16 GMT
From: Brundle <brundlefly76@hotmail.com>
Subject: Interesting behavior of IO::Handle - bug?
Message-Id: <7s984c$86e$1@nnrp1.deja.com>

I have a small program which has a global array of open IO::Handles to
processes.

If I try to print to them using $PIPES[$CURRENTPIPE]:

print $PIPES[$CURRENTPIPE] $stuff;

I get 'scalar found where operator expected';

But if I simply assign the value of the array index to another scalar,
it works as expected:

$currentpipe=$PIPES[$CURRENTPIPE];
print $currentpipe $stuff;

Why would this be?


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Wed, 22 Sep 1999 00:54:17 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Interesting behavior of IO::Handle - bug?
Message-Id: <ZMVF3.2335$QJ.92280@typ11.nn.bcandid.com>

In article <7s984c$86e$1@nnrp1.deja.com>,
Brundle  <brundlefly76@hotmail.com> wrote:
>But if I simply assign the value of the array index to another scalar,
>it works as expected:
>
>$currentpipe=$PIPES[$CURRENTPIPE];
>print $currentpipe $stuff;
>
>Why would this be?

I saw something about it the other day -- either in Tom's FMTYEWTK
about filehandles or in the FAQ.  You should be able to say print
{$PIPES[$CURRENTPIPE]} $stuff.  I didn't understand why.  Filehandles
are brain-damaged.

#!/usr/bin/perl -w
use strict;
# confirm that print {$a[$b]} $c works.
my @a = (\*STDOUT);
my $b = 0;
my $c = "hello\n";
print {$a[$b]} $c;
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Tue Sep 21 1999
48 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Tue, 21 Sep 1999 20:56:01 -0400
From: mcmorran@norfolk.infi.net (Peter McMorran)
Subject: Re: mkdir(). What am I doing wrong?
Message-Id: <37e82a75$1$zpzbeena$mr2ice@news.norfolk.infi.net>

In <7s855a$3gr$1@gxsn.com>, on 09/21/99 
   at 03:40 PM, "Daniel Vesma" <daniel@vesma.co.uk> said:

>Hi Guys,

>I am trying to get a script to create an empty directory with
>wide-open CHMOD settings.

>I am using this...

>use CGI qw(param);
>print "Content-type: text/html\n\n";
>$foo = param("foo");
>$makeDIR = "/my/path/is/here/" . $foo;
>mkdir($makeDIR, 777);
>print "YAY";

>It creates the directory, but when I try to go to them in ie5, I
>get the error...

>Forbidden
>You don't have permission to access /****/****/ on this server.

>The ****s just represent the name of the directory.

>Any ideas? Please? Aww, come on. Please? I love you! Please?

I know there's been considerable discussion on the protections
for the directory, and that's good. But here are a couple of
other thoughts.

Are you sure it created the directory? You must have write access
to the directory that contains the created directory. Your
example shows a full path, suggesting an attempt to create a
directory in the root, which probably won't work.

Second, there are two ways for the browser to access files in a
directory. One is using file:///path/file, when running on the
same host. The other is via http through a web server. Most
servers have pretty restricted ideas about what files they will
access (the WebSpace). This is to make it harder for hackers to
walk through the filesystem. I think maybe this is your ultimate
problem.


Cheers,
Peter

-- 
-----------------------------------------------------------
mcmorran@norfolk.infi.net (Peter McMorran)
-----------------------------------------------------------



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

Date: Tue, 21 Sep 1999 17:27:15 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: Preserving file name of uploaded file
Message-Id: <37E82263.731CFCF9@cisco.com>

[ Burt Hwang wrote:

> Is there a way to store that path of the uploaded file when it gets to
> my CGI?

If your upload form had something like --
<INPUT TYPE="file" NAME="upload" VALUE="" SIZE=60>
the the filename on the server side will be
 my $file =  $CGIObject -> param('upload');
Make sure that this is defined and create the file
to store uploaded contents in this file.
--



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

Date: Tue, 21 Sep 1999 18:08:36 -0700
From: David Amann <dove@synopsys.com>
Subject: Re: Preserving file name of uploaded file
Message-Id: <37E82C14.DC8A49D3@synopsys.com>

Hi Burt,

Burt Hwang wrote:

> Is there a way to store that path of the uploaded file when it gets to
> my CGI?  I don't even know if it is passed along with the actual content
> of the uploaded file.  What I want to do is to save the file on my web
> server as "info.doc".
> 

You can modify this script.  It should do the trick.  I have a couple of
blocks in it where I have to turn the 'strict' pragma off.  I'm not sure
why.

Hope this helps,
-=dav

#!/usr/local/bin/perl-5.004 -wT

# file_upload.cgi
# Author: Dav Amann (dove@synopsys.com)
# Version: 1.0
#
# This script is an example of how to build a file upload style of
# cgi. It's heavily based on Lincoln Stein's example in "The Official
# Guide to Programming with CGI.pm.  
#
# This file will print out a form to upload the file, upload the file
# and save it as the same file name of the uploaded file, and print
# out results about the file.

use strict;

use CGI qw/:standard/;
use CGI::Carp qw/fatalsToBrowser/;
use File::Basename;


# Main program

fileparse_set_fstype("MSDOS");  # This is used by the File::Basename
                                # module to determine the rules on how
                                # to split up the full filename into
                                # the dir name and the file name.  A
                                # routine to set the correct fstype
                                # based upon the User-Agent field of
                                # of the browser is left as an exercise.

print header,
    start_html("File Upload Script"),
    h1("File Upload Script Example");

if (param) {
    save_file();
    print_results();
} else {
    print_upload_form();
}
# Subroutines

sub print_upload_form {
    print 
        start_multipart_form(),
        filefield("-name"   => "upload",
                  "-size"   => "60"), br,
        submit("-label" => "Upload Form"),
        end_form();
}

sub save_file { 

    my $file = param('upload');
    my $path = $file;
    my $filename = basename($path);
    my $data;

    open (SAVE, ">$filename") 
        or die "Can't open $filename: $!\n";

  UNSTRICT: {
      no strict;
      while (read($file, $data, 1024)) {   # I use the read here
                                           # rather than the < >
                                           # to handle binary files
                                           # such as images easier.
          print SAVE $data 
              or die "Can't write $filename: $!\n";
      }

      seek($file, 0, 0) or die "Can't rewind $file: $!\n";
  }



    close SAVE 
        or die "Can't close $filename: $!\n";
}

sub print_results { 
    
    my $file = param('upload');
    my $length;
    my $mime_type = uploadInfo($file)->{'Content-Type'};

    if (!$file) {
        print "No file uploaded\n";
    }

    UNSTRICT: { 
        no strict 'refs';
        while (<$file>) {           # This line here doesn't work when I
                                    # use strict on.  I don't know 
                                    # why.  The error that I get is
                                    # Can't use string "blah" as
                                    # symbol ref.  
            $length += length($_);
        }
    }
    print h2("File Name"), $file;
    print h2("File Mime Type"), $mime_type;
    print h2("File Length"), $length;

    
}


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

Date: Wed, 22 Sep 1999 01:55:49 GMT
From: "Craig Vincent" <2bunnyhop@home.com>
Subject: Problem doing authentication with Apache::DBI
Message-Id: <FGWF3.2459$zl1.30672@news2.rdc1.on.home.com>

I am attempting to do basic authentification thru Mysql.

I have installed the Apache::DBI && Apache-DBILogin modules.
DynaLoader, DBI::Mysql and DBD::Mysql are all the most recent as well.

The newest version of Modperl is installed on Apache 1.3.9 on a BSDi 4.x
machine.

When I attempt to use the authentication...it prompts for a username and
password,
but then I get an Internal Server Error the minute I click okay...whether
the username/password is correct or not.

In the error logs this is what I get:

[Wed Dec 22 04:43:16 1999] [error] install_driver(mysql) failed: Can't load
'/us
r/local/lib/perl5/site_perl/5.005/i386-bsdos/auto/DBD/mysql/mysql.so' for
module
 DBD::mysql: File not found at
/usr/local/lib/perl5/5.00503/i386-bsdos/DynaLoader.pm line 169.
 at (eval 18) line 3 at
/usr/local/lib/perl5/site_perl/5.005/Apache/AuthDBI.pm line 246

Here is the .htaccess file I'm using:

AuthName DBI
AuthType Basic

PerlAuthenHandler Apache::AuthDBI::authen
PerlAuthzHandler Apache::AuthDBI::authz

PerlSetVar Auth_DBI_data_source  dbi:mysql:localhost
PerlSetVar Auth_DBI_username     undef
PerlSetVar Auth_DBI_password     undef
#DBI->connect($data_source, $username, $password)

PerlSetVar Auth_DBI_pwd_table   users
PerlSetVar Auth_DBI_uid_field   username
PerlSetVar Auth_DBI_pwd_field   password

# authentication: SELECT pwd_field FROM pwd_table WHERE uid_field=$user

PerlSetVar Auth_DBI_grp_field   password
# authorization: SELECT grp_field FROM pwd_table WHERE uid_field=$user

require valid-user

In the httpd.conf file I have the commands
PerlModule Apache::DBI
PerlModule Apache::AuthDBI

I don't know what could be wrong...any suggestions?

Craig Vincent




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

Date: Wed, 22 Sep 1999 00:37:54 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Problem with method - unblessed
Message-Id: <CxVF3.83$ml3.6331@nsw.nnrp.telstra.net>

In article <37E7F09A.55F444DF@apk.net>,
	"R. Brockway" <rockie@apk.net> writes:

> I'm stuck and am still trying to learn methods/classes, etc. The call at

It's not your grasp of OO, but the fact that you didn't rigorously
adhered to the rule:

use strict! use strict! use strict!

> line 43 (code follows) looks to me to be using a known package (RPC),
> but apparently I'm fully missing something. If anyone could help me
> figure it out i'd greatly appreciate it (or but you a beer if you're
> ever in cleveland.

You can send me a beer by mail :)

> #!/usr/bin/perl -wT

good. -w.

> use 5.005;
> #use strict;

Ooooh.. bad. This would have _told_ you where the problem most likely
lies.

Please, put it back asap.

use strict;


> sub get_user {
>         # take $username and grep from /etc/passwd
>         my ($con, $username);
>         $cmd = ("grep $username /etc/passwd");

Need to scope $cmd here.

		my $cmd = ("grep $username /etc/passwd");

You know that perl has a bundle of builtins for this, which will work
much better?

# perldoc perlfunc
Look at the getpw* functions.

# perldoc User::pwent

> # Function server
> sub server ($) {
>         # process client requests, set up function table
>         my ($con) = shift;
>         my ($con, %funcTable);

Duplicate scoping of $con! This means that the $con that the rest of
this code will see is _undefined_.

	my $con = shift;
	my %funcTable;

> ########### Bad Line Below, shame on you ###############
>           if (!$con->Loop()) {

And indeed. The error message you get corresponds to un andefined
value here.

# perldoc perldiag
     Can't call method "%s" on unblessed reference
         (F) A method call must know in what package it's
		 supposed to run.  It ordinarily finds this out from the
         object reference you supply, but you didn't supply an
		 object reference in this case.  A reference isn't an
		 object reference until it has been blessed.  See the
         perlobj manpage.

> my $sock = IO::Socket::INET->new('Proto' => 'tcp',
>                         'Listen' => 3,
>                         'LocalPort' => 13000
>                         );

I'd also advise you to check whether this succeeded.

> while (1) {
>         # add configFile to this next line eventually
>         my $con = new RPC::pServer('sock' => $sock);
>         if (!ref($con)) {
>                 print STDERR "Cannot Create Server!: $con\n";

And to do something more dramtic than just warning on this error. I
mean, how useful is it to not die on an error of this magnitude?

Martien
-- 
Martien Verbruggen                  | 
Interactive Media Division          | Failure is not an option. It comes
Commercial Dynamics Pty. Ltd.       | bundled with your Microsoft product.
NSW, Australia                      | 


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

Date: Wed, 22 Sep 1999 00:08:09 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Some e-mails get sent, some don't
Message-Id: <J5VF3.67$ml3.5445@nsw.nnrp.telstra.net>

In article <7s8ht6$2cb@junior.apk.net>,
	catfood@apk.net (Mark W. Schumann) writes:

> My comment: and won't Perl catch these things if you leave taint
> checking on?  There's a _reason_ for taint checking.

Nono.. That's not what perl's taint checking is about. Perl's taint
checking is there to warn you about which variables, paths etc may be
dangerous. It cannot examine the contents of the variables for you,
because it can't really know what they mean. It can also not examine
the effects or implications of a full command, because it can't know
whether that is what you really intended.

In the case of open, sure. perl could extrapolate the variables, and
make a guess about what's safe, and what isn't. But it could be wrong.

open(IN '| some_filter | $mail $addr');

Now... which of these pipes is 'safe' and which isn't? 

Of course it could only look at the contents of $addr, but you may
still want to have shell characters in there, even though perl might
now like it. In other words: Anything that perl might _assume_ might
not be what you want. And if you make that assumption configurable,
you're back at exactly the same point where we are: You define what's
safe, and what isn't.

That's why taint mode just tells you what's suspect, and relies on you
to clean it up.

Martien
-- 
Martien Verbruggen                  | 
Interactive Media Division          | Never hire a poor lawyer. Never buy
Commercial Dynamics Pty. Ltd.       | from a rich salesperson.
NSW, Australia                      | 


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

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 V9 Issue 871
*************************************


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