[10531] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4123 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Nov 1 07:07:27 1998

Date: Sun, 1 Nov 98 04:00:21 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sun, 1 Nov 1998     Volume: 8 Number: 4123

Today's topics:
    Re: Compare 2 files (Tad McClellan)
    Re: CPAN module <shulman@caltech.edu>
    Re: Help -- Need Sybperl <mpersico@erols.com>
    Re: help a poor student <rra@stanford.edu>
    Re: How does one sort associative array numerically? (Tad McClellan)
        It works , but why (Owen Cook)
    Re: It works , but why <ljz@asfast.com>
    Re: Multiple edits, multiple files (Tad McClellan)
        multiprocess/thread logic <ask@netcetera.dk>
        Newbie - Calling Perl From Delphi + Distribution Issues (Chris Brooksbank)
    Re: Not to start a language war but.. <uri@sysarch.com>
    Re: Not to start a language war but.. (William Tanksley)
    Re: Not to start a language war but.. <rra@stanford.edu>
        Perl Institute: User Survey <gnat@frii.com>
        Perl, DBI and Apache <info@edoc.co.za>
    Re: Perl, DBI and Apache <csoren@isd.net>
    Re: Perl, DBI and Apache (Sam Holden)
    Re: problem with modules in a compiled perl script (Charles J. Leslie)
    Re: text files versus dB <rra@stanford.edu>
    Re: uninstalling modules <mpersico@erols.com>
    Re: What is the "correct" location of perl under Solari <rra@stanford.edu>
    Re: What's with these Curly brackets??? <mpersico@erols.com>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Sun, 1 Nov 1998 00:38:26 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Compare 2 files
Message-Id: <2lvg17.q58.ln@flash.net>

Simon B. (webmaster@ouweb.com) wrote:
: Hello, I need a CGI perl script that can compare 2 files and if it find
: duplicate entries in one of the two files than it delete one line in one of
: the database...

: Please answer me...
         ^^^^^^

   OK, but you didn't ask a question...  ;-)


   Show us the code you have so far, and we will help you 
   make it work.


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


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

Date: Sat, 31 Oct 1998 22:03:17 -0800
From: Michael Shulman <shulman@caltech.edu>
Subject: Re: CPAN module
Message-Id: <363BF9A5.FE42399E@caltech.edu>

Okay, now I have another problem. Whenever I try to install something, I
get the error message:
Makefile:698: *** missing separator.  Stop.
And from that point on nothing works. Can anyone tell me what to do?
Thanks.

________________________________________________________________________
|    \/|R|TR|LB|/\    | QOTD: "The mind of a bigot is like the pupil   |
|   Michael Shulman   |  of the eye. The more light you shine on it,   |
| shulman@caltech.edu |  the more it will contract."  -Oliver Wendell  |
|                     |  Holmes, Jr.                                   |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


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

Date: Sat, 31 Oct 1998 23:17:27 -0500
From: "Matthew O. Persico" <mpersico@erols.com>
To: Michael Peppler <mpeppler@mbay.net>
Subject: Re: Help -- Need Sybperl
Message-Id: <363BE0D7.D86DF6D8@erols.com>



Michael Peppler wrote:
> 
> Monty Taylor wrote:
> >
> > I would like to play with Sybperl or DBD:Sybase to do things a tad more
> > directly. However, I don't have a compiler on the Windows side and the UNIX
> > admins here don't believe Perl should be used in production, so they won't
> > install any bits for me (SMITE THEM ALL! It's SO frustrating not being an
> > admin)
> 
> That is the most backward policy I have seen in a long time!
> 

WHAT the HELL is their rationale for THAT policy? And yes, I do know 
that I am yelling.

-- 
Matthew O. Persico
Nothing even remotely clever at the moment.


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

Date: 31 Oct 1998 23:29:33 -0800
From: Russ Allbery <rra@stanford.edu>
Subject: Re: help a poor student
Message-Id: <ylr9vnvpk2.fsf@windlord.stanford.edu>

brian d foy <comdog@computerdog.com> writes:
> "James Greenhalgh" <mghalgh@goulburn.net.au> posted:

>> We have to design a stupid text adventure in a language of our choice
>> for school. I know bugger all about perl but I want to learn. It
>> probably seems simple to anyone except a retard like me but what gives
>> with this script?  msg me at mghalgh@goulburn.net.au . And could the
>> smart arse programmers who do it for a living please give the insults a
>> miss.

> you seem to have the insults adequately covered.

If you want a serious response to this, and if you can *really* choose the
language of your choice, choose a text adventure design language rather
than any general programming language.  You'll find it *far* easier to
write a text adventure game in Z-code (version 3 or version 5) than you
will in anything general purpose like Perl.

You can get the Inform compiler for Z-code from the interactive fiction
archives at <URL:ftp://ftp.gmd.de/if-archive/infocom/compilers/>.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: Sat, 31 Oct 1998 21:33:26 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: How does one sort associative array numerically?
Message-Id: <6qkg17.jk7.ln@flash.net>

Loans2001 (loans2001@aol.com) wrote:
: I wrote this program. I don't understand why when the file is read in via STDIN
: why when it is printed out, it's not in any order. 


: If anyone could shed some light on this, I'd really appreciate it. 


   Because that is how the Hash data structure works.

   The order is determined by how the data structure is implemented.


: I tried the
: Learning Perl book. I couldn't figure out how to sort it ascending by loan
: amount.


   Perl FAQ, part 4:

   "How do I sort a hash (optionally by value instead of key)?"


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


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

Date: Sun, 01 Nov 1998 05:46:37 GMT
From: rcook@pcug.org.au (Owen Cook)
Subject: It works , but why
Message-Id: <363be90d.418815@newshost.pcug.org.au>

In a file creation routine, I used this line (adapted from someone elses)
but didn't know why it worked.

($j < 10)  and ($j = "00$j");

So I replaced it with this. 

if ($j < 10){$j = "00$j"}

I can verbalise this one, ie, IF $j is less than 10 THEN $j is 00$j

What words can be used to describe what the first line does?
(if this first bracket is true) MAKE (this next bracket true) ?


Owen



complete listing
_______________________________________________________
#!/opt/contrib/bin/perl

#$summary_file = 'tassets.txt';
open (FILE,"tassets.txt") or die "Couldn't open the file $!\n";
$j=0;
while (<FILE>){
	@rows = split ("\t");
	$j=$j+1;
	#($j < 10)  and ($j = "00$j");
	if ($j < 10){$j = "00$j"}
	($j >9) and ($j<100) and ($j = "0$j");
	$a="Assets$j";

	open (OUT,">$a.txt") or die "Couldn't open the file $!\n";
	print OUT"$rows[6]\t$rows[8]\n ";
	close (OUT);
}
close (FILE);
exit(0);






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

Date: 01 Nov 1998 01:04:32 -500
From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: It works , but why
Message-Id: <lt7lxglzin.fsf@asfast.com>

rcook@pcug.org.au (Owen Cook) writes:

> In a file creation routine, I used this line (adapted from someone elses)
> but didn't know why it worked.
> 
> ($j < 10)  and ($j = "00$j");
> 
> So I replaced it with this. 
> 
> if ($j < 10){$j = "00$j"}
> 
> I can verbalise this one, ie, IF $j is less than 10 THEN $j is 00$j
> 
> What words can be used to describe what the first line does?
> (if this first bracket is true) MAKE (this next bracket true) ?

The 'and' operator in Perl is a "short circuit" operator.  What that
means is that if the left-hand operand of 'and' is false, the
right-hand operand is guaranteed not to be evaluated at all.
Conversely, if the left-hand operand is true, this causes the
right-hand operand to always be evaluated.

Therefore, in your example, ($j = "00$j") is not evaluated unless
($j < 10) is true.  In your example, this is equivalent to
if ($j < 10) { $j = "00$j" }.

Because of this behavior,   "A and B"   is often coded instead of
"if (A) { B }".   Similarly,  "A or B"   is often coded instead of
"if (!A) { B }".

Also note that the '&&' and '||' operators also behave as "short
circuit" operators in this manner.

-- 
 Lloyd Zusman   ljz@asfast.com
 perl -le '$n=170;for($d=2;($d*$d)<=$n;$d+=(1+($d%2))){for($t=0;($n%$d)==0;
 $t++){$n=int($n/$d);}while($t-->0){push(@r,$d);}}if($n>1){push(@r,$n);}
 $x=0;map{$x+=(($_>0)?(1<<log($_-0.5)/log(2.0)+1):1)}@r;print"$x"'


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

Date: Sat, 31 Oct 1998 22:02:26 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Multiple edits, multiple files
Message-Id: <igmg17.io7.ln@flash.net>

Drew Simonis (care227@ibm.net) wrote:
: This is a multi-part message in MIME format.
                               ^^^^^^^^^^^^^^

   Please don't do that.

   Usenet runs on plain text. Your "newsreader" is misconfigured.


: I recently inherited a web site from a departed co-worker.  I am now
: responsible for over 800 pages of content.  Make that 800 pages of
: content lacking ISO-9000 document control pages.  I have 3 days to add
: this information to these pages or else!


   No problem.


: So here's what I have...
: I need a script (awk, sed, perl or shell) to do the following, and I am
: having alot of difficulty (a newbie to scripting here)


   With large volume and short deadline you kinda got a problem
   there. Even with the below, you are going to need to become
   a programmer in less that 72 hours.

   Good luck Jim.


: In psuedo code:

: take the value located between the <title> and </title> and hold it.

: Search for </body> and replace it with:

: Name of the document: RECALL STORED VALUE HERE
: Owner of document: Manager Department PT4

[snip]

: </body>


: I need to make these changes to 800 documents 


   use File::Find;


: and then write the edits
: back to the origional document.  


   see the -i switch in the 'perlrun' man page.


: Can anyone help?  Point me in the
: correct direction?


------------------------------------------------
#!/usr/bin/perl -w

undef $/;
$_ = <>;   # slurp. Not So Good for largish files...

$title = $1 if m#<title>(.*?)</title>#si;   # find the first title tag pair

$iso9000 =<<END9000;              # insert the title into the boilerplate
Name of the document: $title
Owner of document: Manager Department PT4
yada
yada
yada
END9000


s#</body>#$iso9000</body#;   # do the substitution

print;                       # output the slurped file
------------------------------------------------


Of course the above is a dirty hack that will not work correctly
in all cases. But how to do it robustly (use HTML::Parse) is
covered in several question in part 9 of the Perl FAQ...


: At least pity me?


   I pity all those who apply "encoding" to plain text.



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


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

Date: 31 Oct 1998 19:42:03 +0100
From: Ask Bjoern Hansen <ask@netcetera.dk>
Subject: multiprocess/thread logic
Message-Id: <m3d878tvyc.fsf@ratatosk.netcetera.dk>

Hi,

I've spent most of the day trying to get a program with threads
working.  But it fails on the most unexpected places.  I could get 

my $thr = new Thread \&FooThread;

sub FooThread {
  print "a";
  while (1) { 
    print "b";
    if (1) {
      print "c";
      ...

to just print 'ab'. (using 5.005_51 on linux/glibc) (In a slightly
larger program, but I can't imagine what should make this happen? -
the other threads continued just fine).  

Anyway, now I want to write the program using processes instead, but
I don't know where to start (well, I suppose that fork and waitpid is
what I need..)

The program is quite simple. Using threads I implemented it like this:
An 'outqueue' with data from a database to be processed, an 'inqueue'
with processed data to be stuffed back to the database now and
then. I've some clients connecting to get n datablocks to process, and
return what it have finished.

I had 4(+) threads.  I used Thread::Queue for the queues.

1) QueueBufferHandler - Got new data from the database when the
   'outbuffer' got too small.
2) RecievedBufferHandler - Ate from the 'inqueue' and returned the
   data to the database.
3) ServerHandler - '$client = $server->accept'ed and stuffed the
   $client's into yet another Thread::Queue.
0) Thread 0 looped around $clientqueue->dequeue_nb and started a new
   thread for every incomming $client ("4+").  This could also be done in
   thread 3, oh well.
4+)ClientHandlers - These threads enqueues the inqueue or dequeues the
   outbuffer on the clients requests.

Except for by QueueBufferHandler halting very often in a construct
like the one above, it worked all right.

What's the best way to implement this using "real" processes?

How can I make it prefork the 'ClientHandler' processes like Apache?

It's important that I only have 1 inqueue and 1 outqueue.

Any good advices?


on a sidenote: what am I missing when my compile of 5.005_53 (with
threads) ends like this (still on a linux/glibc system):

cc -c  -D_REENTRANT -Dbool=char -DHAS_BOOL -O2    -DVERSION=\"1.0\" -DXS_VERSION=\"1.0\" -fpic -I../..  Thread.c
Thread.xs: In function `newthread':
Thread.xs:232: `ATTR_JOINABLE' undeclared (first use this function)
Thread.xs:232: (Each undeclared identifier is reported only once
Thread.xs:232: for each function it appears in.)
make[1]: *** [Thread.o] Error 1 

5.005_51 compiled fine.

-- 
ask bjoern hansen - <http://www.netcetera.dk/~ask/>
Perl Usage Survey - <http://www.perl.org/cgi-bin/survey>


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

Date: Sun, 01 Nov 1998 07:32:53 GMT
From: ChrisChelmsford@Hotmail.com (Chris Brooksbank)
Subject: Newbie - Calling Perl From Delphi + Distribution Issues
Message-Id: <363c0deb.3547321@news.dial.pipex.com>

I am a Delphi programmer of some years experience. Pascal seems very
ineffecient for parsing messages so I am looking at Perl ( to parse
S.W.I.F.T messages ). Am I right in thinking PerlEZ will allow me to
run Perl code from my Delphi App. Does this start up a command
session. To distribute the app would the clients need the full Perl5
installation or just this DLL 


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

Date: 01 Nov 1998 00:23:19 -0500
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Not to start a language war but..
Message-Id: <x7sog4c7g8.fsf@sysarch.com>

>>>>> "TH" == Tim Haynes <piglet@richard.lse.ac.uk> writes:

  TH>  On Thu, 29 Oct 1998, Larry
  TH> Rosler wrote:

  >> > And where does the "max 80 column text" idea come from?  In
  >> addition to the history that Uri Guttman expounded on, it happens
  >> also to be the Usenet standard, for similar good reasons.  We are
  >> encouraged to set our line wraps at 72 columns in order that
  >> multiple quoting indents not push the lines over 80 columns.

  TH> <semi-serious not-completely-troll> <rant> What I don't understand
  TH> is why, in the days of vim and emacs where we have paragraph
  TH> auto-formatting, we should go out of our way to accommodate the
  TH> next W**d*ze (l)user coming along with an editor that cannot wrap
  TH> quoted text properly.  IMO it looks daft to see ng posts only
  TH> using about half the screen "for other people's benefit".  </rant>
  TH> </s-s n-c-t>

i am confused about your meaning here. are you for or against using 80
column (or 72) formatting on usenet posts or on code or what?

how is using a good editor like emacs accomodating to a winblows user?
it is more like they are not accomodating to us sine their
newsreaders/editors don't understand fixed width formats like code and
usenet. they assume dynamic wrapping with variable width chars to
whatever size they feel is cool. the fact that it looks mangled on most
other readers/editor seems irrelevent to them. and forget about
intelligent quoting and indenting. thye just grab the old post, prefix
with > and put it after the new message with no editing encouraged. just
another way uncle bill snubs the internet and established customs and
norms. if he don't own it, ho don't give a fart. BTW there are surveys
whiich have lusers saying they think uncle bill owns the internet! scary
halloween thought even if false!

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire  ----------------------  Perl, Internet, UNIX Consulting
uri@sysarch.com  ------------------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Sun, 01 Nov 1998 08:31:57 GMT
From: wtanksle@cx930311-b.ocnsd1.sdca.home.com (William Tanksley)
Subject: Re: Not to start a language war but..
Message-Id: <slrn73o73t.1ad.wtanksle@cx930311-b.ocnsd1.sdca.home.com>

In article <909712475.164200@thrush.omix.com>, Zenin wrote:
>Austin Schutz <spamsux-tex@habit.com> wrote:
>	>snip<
>: 	It would be really swell if someone were to write a perl programmer's
>: roadmap to python. I've never really been able to get very
>: far with it because my brain is pretty perl-ized in terms of ways to
>: structure data (shove it all in a hash) and my purely lazy attitude.

Go ahead -- that'll work perfectly in Python too.

>	I've always thought a Python programmer's roadmap to Perl would
>	be far more useful. :-)

Indeed it would!  I could really use that, and I think it would have some
widespread use.  Many Python programmers are forced into using Perl because
of idiots who think Perl has some exclusive capability (bosses, ya gotta...
never mind).  In that state of mind just about everything in Perl is a
personal insult ;).

You know what I mean?

At this point, I can read Perl, but the thought of writing it causes faint
nausea.  Except for text processing; the Perl while(<WHATEVER>) syntax is
much, much better than any of the Python syntax to do the same thing... let
me see:

for line in file.readlines(): # nice, but eats memory

line = file.readline()
while line:
  do ( something )
  line = file.readline()  # better, but too redundant

There has to be a better way here.

I use Python as pseudocode, and then I compile and run my pseudocode, thus
testing whether I got it right.  I hand it in to my teacher, and so far
thay've never suspected.  For bigger projects I plan to start using nuweb or
noweb, and writing the whole thing in pseudocode.  :-).

But anyhow, now I gotta write this huge processing-intensive app in Perl.
Grr.

>-Zenin (zenin@archive.rhps.org)           From The Blue Camel we learn:

-Billy


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

Date: 31 Oct 1998 23:22:47 -0800
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Not to start a language war but..
Message-Id: <ylu30jvpvc.fsf@windlord.stanford.edu>

In comp.lang.perl.misc, Michael P Reilly <arcege@shore.net> writes:
> In comp.lang.python Russ Allbery <rra@stanford.edu> wrote:

>> There's a problem with this argument.  How much information are you
>> losing by relying on the exception?  I would, when coding the above in
>> Perl (and likely in Python as well) specifically say *what* I was doing
>> that failed in each case, not just say something generic like "open
>> failed".  I want the file name, the operating system error code, and
>> (this is the hard part) the conceptual piece of work the program was
>> attempting to do at the same time.

> No language, to my knowledge, has an intrinsic "conceptual" view of the
> execution.

Right.  That's exactly my point.  If I want conceptual error information
propagated along with my error (and in general I definitely *do* want
that), I'd have to throw my own exception.  That, at least to me,
significantly reduces the usefulness of Python's automatic exception
throwing, since if I want production-quality error reporting I can't use
that anyway.

This isn't a complaint about what Python does, btw.  Obviously it *can't*
do much better.  I'm just pointing out that automatically throwing
exceptions isn't as big of an advantage over Perl for production code as
it may sound.

> If you want to throw an exception with conceptual information, then
> you'll have to do it yourself, in any language: Perl, Python, Tcl, C.

Exactly.

> Perl still has the confusion that $!/$OS_ERRNO is a string AND a number
> with a different value, which contradicts how scalars are documented to
> work (in general).

It's not a confusion.  It's a case of DWIM.  As a Perl programmer, I
greatly appreciate the behavior.  Yes, it totally violates the notion that
a programming language should be based on a minimal set of axioms and
never contradict those axioms; Perl happy violates that notion all over
the place.  Having programmed in both types of languages, I know what
approach I prefer, and I also know that I'm unlikely to change the mind of
people who disagree with me.  :)

> FYI: I was a Perl scripter for more than four years.  Then Perl 5 came
> out; I laughed in dismay and started looking for something better.

Choice is a good thing.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: 31 Oct 1998 09:53:40 -0700
From: Nathan Torkington <gnat@frii.com>
Subject: Perl Institute: User Survey
Message-Id: <5qyapwekq3.fsf@prometheus.frii.com>

The Perl Institute is conducting an informal survey of Perl users, via
the web.  Participate by pointing your browsers at:
        http://www.perl.org/cgi-bin/survey

This survey was designed by the members of the Perl advocacy mailing
list, headed by Ask Bjoern Hansen (who also did the programming).
While the results can't by any means be taken as indicative of the
entire Perl user community, we feel they will be interesting in their
own right.

Nat


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

Date: Tue, 27 Oct 1998 18:12:32 +0200
From: Nico <info@edoc.co.za>
Subject: Perl, DBI and Apache
Message-Id: <3635F0F0.79A7@edoc.co.za>

Hi,

If this message does not belong here, please direct me to the correct
place.

I'm trying to write a web interface with a Mysql database.

I installed everything according to the manual, but have problems.

I wrote a crude script to test the interface (see below).

When run from the commandline (./select.pl), the wanted output runs
across the screen.

When run from http://..../cgi-bin/select.pl, I get an error message in
my errorlog:

[Tue Oct 27 17:18:37 1998] [error] Can't load
'/usr/lib/perl5/site_perl/i586-linux/auto/DBI/DBI.so' for module DBI:
Unable to resolve symbol at
/usr/lib/perl5/i586-linux/5.00404/DynaLoader.pm line 166.

 at /usr/lib/perl5/site_perl/DBI.pm line 164
BEGIN failed--compilation aborted at /usr/lib/perl5/site_perl/DBI.pm
line 164.
BEGIN failed--compilation aborted at
/usr/local/httpd/cgi-bin/selector.pl line 5.


The file '/usr/lib/perl5/site_perl/i586-linux/auto/DBI/DBI.so' does
exist.

Any suggestions, as this is driving me crazy.

Thanks

Nico

select.pl

#!/usr/bin/perl
#
use strict;
use CGI;
use DBI;                    # Line 5

# Print HTML header
print "Content-type: text/html";
print "<body><html>\n";

#Connecting to mysql database

my $dbname = 'DBI:mysql:medpages';
my $dbn = DBI->connect( $dbname,'xxxx', 'xxxx') || die "can not connect
$DBI::errstr";

#Get data from database
my( $code, $region, $category, $phone);

# Prepare the statement for execution
         my   $sth =$dbn->prepare( "SELECT initials, lastname, pracname,
physad1, physad2, physad3, telephone FROM dokters WHERE
(service='Gynaecologist & Obstetrician') AND (physad3 ='Durban')" );
            if ( !defined $sth ) {
                die "Cannot prepare statement: $DBI::errstr\n";}    
                    
            # Execute the statement at the database level
            $sth->execute;

            # Fetch the rows back from the SELECT statement
            while (  my @row = $sth->fetchrow() ) {
           print "Row returned: @row<br>";}
     
         #Finished with SQL

            # Release the statement handle resources
            $sth->finish;

            # Disconnect from the database
            $dbn->disconnect;


# Close HTML

print "</body></html>\n";


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

Date: Sun, 01 Nov 1998 02:22:01 -0600
From: Chris Sorenson <csoren@isd.net>
Subject: Re: Perl, DBI and Apache
Message-Id: <363C1A29.82E2E074@isd.net>



Nico wrote:

> Hi,
>
> If this message does not belong here, please direct me to the correct
> place.
>
> I'm trying to write a web interface with a Mysql database.
>
> I installed everything according to the manual, but have problems.
>
> I wrote a crude script to test the interface (see below).
>
> When run from the commandline (./select.pl), the wanted output runs
> across the screen.
>
> When run from http://..../cgi-bin/select.pl, I get an error message in
> my errorlog:
>
> [Tue Oct 27 17:18:37 1998] [error] Can't load
> '/usr/lib/perl5/site_perl/i586-linux/auto/DBI/DBI.so' for module DBI:
> Unable to resolve symbol at
> /usr/lib/perl5/i586-linux/5.00404/DynaLoader.pm line 166.
>
>  at /usr/lib/perl5/site_perl/DBI.pm line 164
> BEGIN failed--compilation aborted at /usr/lib/perl5/site_perl/DBI.pm
> line 164.
> BEGIN failed--compilation aborted at
> /usr/local/httpd/cgi-bin/selector.pl line 5.
>
> The file '/usr/lib/perl5/site_perl/i586-linux/auto/DBI/DBI.so' does
> exist.
>
> Any suggestions, as this is driving me crazy.
>
> Thanks
>
> Nico
>
> select.pl
>
> #!/usr/bin/perl
> #
> use strict;
> use CGI;
> use DBI;                    # Line 5
>
> # Print HTML header
> print "Content-type: text/html";
> print "<body><html>\n";
>
> #Connecting to mysql database
>
> my $dbname = 'DBI:mysql:medpages';
> my $dbn = DBI->connect( $dbname,'xxxx', 'xxxx') || die "can not connect
> $DBI::errstr";
>
> #Get data from database
> my( $code, $region, $category, $phone);
>
> # Prepare the statement for execution
>          my   $sth =$dbn->prepare( "SELECT initials, lastname, pracname,
> physad1, physad2, physad3, telephone FROM dokters WHERE
> (service='Gynaecologist & Obstetrician') AND (physad3 ='Durban')" );
>             if ( !defined $sth ) {
>                 die "Cannot prepare statement: $DBI::errstr\n";}
>
>             # Execute the statement at the database level
>             $sth->execute;
>
>             # Fetch the rows back from the SELECT statement
>             while (  my @row = $sth->fetchrow() ) {
>            print "Row returned: @row<br>";}
>
>          #Finished with SQL
>
>             # Release the statement handle resources
>             $sth->finish;
>
>             # Disconnect from the database
>             $dbn->disconnect;
>
> # Close HTML
>
> print "</body></html>\n";

Well, obviously your script is never running when it gets called from
Apache, it's stopping because the Perl DBI module isn't compiling.
Specifically, it's stopping on the DBI.so compilation (files with the
extension "so" are runtime-linked libraries, but you already knew that...
:). Now, you state that when you run the script from the command prompt, you
get the correct output. This would indicate that the Perl DBI module is
compiling the shared library when you run from the command prompt. Weird!
Ordinarily, if an executable runs for one user (you), and crashes for
another (Apache, the web server, usually "nobody"), then it's a user
permissions problem. But this doesn't seem like that. Are you certain that
the DBI module is compiling when you run from the command prompt? If it's
not, and I'm guessing it isn't, it's being skipped or bypassed somehow, then
you need to have your sysadmin fix the problem with the DBI module. That
shouldn't be too tough, provided you can convince them to do it. Good luck!



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

Date: 1 Nov 1998 11:05:59 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Perl, DBI and Apache
Message-Id: <slrn73og4n.epk.sholden@pgrad.cs.usyd.edu.au>

On Sun, 01 Nov 1998 02:22:01 -0600, Chris Sorenson <csoren@isd.net> wrote:
>
>
<snip problem with not being able to find .so sometimes>

>Apache, it's stopping because the Perl DBI module isn't compiling.
>Specifically, it's stopping on the DBI.so compilation (files with the
>extension "so" are runtime-linked libraries, but you already knew that...
>:). Now, you state that when you run the script from the command prompt, you
>get the correct output. This would indicate that the Perl DBI module is
>compiling the shared library when you run from the command prompt. Weird!
>Ordinarily, if an executable runs for one user (you), and crashes for
>another (Apache, the web server, usually "nobody"), then it's a user
>permissions problem. But this doesn't seem like that. Are you certain that
>the DBI module is compiling when you run from the command prompt? If it's
>not, and I'm guessing it isn't, it's being skipped or bypassed somehow, then
>you need to have your sysadmin fix the problem with the DBI module. That
>shouldn't be too tough, provided you can convince them to do it. Good luck!

I got burnt once with bdm files when the machine I had shell on, and ftp'd 
everything to was not actually the web server. Which wouldn't be a problem,
except that the two machines were completely different and no one bothered
telling me. So my dbm files which worked on the command line wouldn't work
work in CGI scripts (due to  endian differences). 

-- 
Sam

testing? What's that? If it compiles, it is good, if it boots up it is
perfect.
	--Linus Torvalds


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

Date: Sun, 01 Nov 1998 07:08:45 GMT
From: cjl@gateway (Charles J. Leslie)
Subject: Re: problem with modules in a compiled perl script
Message-Id: <1OT_1.1656$ps1.5707345@news.rdc1.sfba.home.com>

Charles J. Leslie (cjl@gateway) wrote:
: Forgot to mention, I'm using perl5.005_02.

: thanks.

: Charles J. Leslie (cjl@gateway) wrote:
: : I've compiled a simple perl script which uses the Telnet module. However
: : when I try to execute the binary, I get the following error message:

: : Can't locate object method "new" via package "Net::Telnet".


: : The script works fine and perlcc compiles the source without any
: : problems.  What am I missing?  I searched the FAQ to no avail.
: : I've even compiled the Telnet.pm file into a shared library and tried
: : to link the two; no luck.

: : thanks

: : -charles


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

Date: 31 Oct 1998 23:34:53 -0800
From: Russ Allbery <rra@stanford.edu>
Subject: Re: text files versus dB
Message-Id: <yllnlvvpb6.fsf@windlord.stanford.edu>

E-swap <webmaster@eswap.co.uk> writes:

> i am currently running an auction site which is using flat text files
> for each item and user who registers.  how does this affect the
> performance of the site versus using something like MySQL, or any other
> database?

That's an impossible question to answer as phrased, since it depends
entirely on what data you're storing, what searches you're performing, how
much data there is, and what the field types are.

Quite a few things are better stored in flat files using the file system
as your indexing system, since it's easier to poke at things manually when
you need to, you can view and/or change things with a text editor if need
be, and the format is more intuitively obvious to anyone looking at it who
didn't write it.

On the other hand, access times can be slow, and if your fields are
complex the code to parse flat files can be a major pain.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: Sat, 31 Oct 1998 23:27:55 -0500
From: "Matthew O. Persico" <mpersico@erols.com>
To: Aravind Subramanian <aravind@genome.wi.mit.edu>
Subject: Re: uninstalling modules
Message-Id: <363BE34B.24301250@erols.com>

[ cc to poster ]

I have a script that reads the .packlist for a module, figures out what
files are part of it and deletes them. It is at work and it is Saturday
now. I'll mail to you Monday, post Monday night.

Aravind Subramanian wrote:
> 
> I am trying to set up a web page that provides the following
> functionality:
> 
> List currently installed CPAN modules
> Install a CPAN module
> Upgrade a CPAN module
> Uninstall a CPAN module
> 
> CPAN.pm is of great help in doing most of this. Except, I can't figure
> out how to uninstall a perl module (either using CPAN.pm or by some
> other means).
> 
> Any suggestions?
> 
> Thanks,
> aravind

-- 
Matthew O. Persico
Nothing even remotely clever at the moment.


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

Date: 31 Oct 1998 23:32:24 -0800
From: Russ Allbery <rra@stanford.edu>
Subject: Re: What is the "correct" location of perl under Solaris?
Message-Id: <ylogqrvpfb.fsf@windlord.stanford.edu>

Andrew Perrin <aperrin@mcmahon.qal.berkeley.edu> writes:

> We use /usr/local/bin/perl.  Suggestion: whichever you stick it in, put
> a link in the other directory so your scripts don't break.

man perlrun has some discussion of this:

  Location of Perl

    It may seem obvious to say, but Perl is useful only when users can
    easily find it. When possible, it's good for both /usr/bin/perl and
    /usr/local/bin/perl to be symlinks to the actual binary. If that can't
    be done, system administrators are strongly encouraged to put
    (symlinks to) perl and its accompanying utilities, such as perldoc,
    into a directory typically found along a user's PATH, or in another
    obvious and convenient place.

    In this documentation, `#!/usr/bin/perl' on the first line of the
    script will stand in for whatever method works on your system.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: Sat, 31 Oct 1998 23:21:46 -0500
From: "Matthew O. Persico" <mpersico@erols.com>
To: John Hardy <jhardy@cins.com>
Subject: Re: What's with these Curly brackets???
Message-Id: <363BE1DA.925F706C@erols.com>

[ cc to poster ]

Post the ENTIRE script. Then we can take a whack at it. In the meantime,
you need an editor that understands perl. XEmacs is one.
http://www.xemacs.org if you're handly building software.
John Hardy wrote:
> 
> In article <363fa550.6001160@news.ping.be>, bart.mediamind@ping.be says...
> >
> >Matt Knecht wrote:
> >
> >>you're missing a right bracket somewhere else, not in this sub (All your
> >>brackets here have partners in the sub you posted).  Without a good
> >>editor, finding this sort of typo can be a nightmare.
> >
> >What I do, without such an editor, is temporarily remove subs that are
> >ok, or just the opposite: commenting out parts that are suspect. If I
> >get syntax errors with this statement, but not without, then the erro is
> >IN this statement. Easy as that.
> >
> >Temporarily removing things that are ok (put them in other temporary
> >windows, so you wan put them back later) helps the compiler diagnosing
> >more accurately what is wrong.
> >
> >        Bart.
> 
> I have counted all the brackets and there are 7 - 7 through the whole script,
> so thats a match and they all seem to be in the right place.
> 
> When I take the sub out of the script it works fine, yet the sub also works
> fine on it's own??? I put in another sub to test, very short
> 
> sub test_ing {
> 
> print "this is a test \n";
> 
> }
> 
> and perl tells me that the last bracket is a syntax error, when I take it
> out it tells me it's missing?????????????????????
> 
> I'm begining to think it must have something to do with my editor although it
> is a very sinple editor that I have always used (Ultra Edit)
> 
> All other scripts are running fine, so I din't know??!!
> 
> 

-- 
Matthew O. Persico
Nothing even remotely clever at the moment.


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

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

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