[11551] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5151 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 16 19:07:19 1999

Date: Tue, 16 Mar 99 16:00:27 -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           Tue, 16 Mar 1999     Volume: 8 Number: 5151

Today's topics:
    Re: 1000 thread limit? <sugalskd@netserve.ous.edu>
        Can someone please help me with this counter script! <rollo@enter.net>
    Re: Can someone please help me with this counter script (Hakan Ardo)
    Re: Can someone please help me with this counter script <jglascoe@giss.nasa.gov>
    Re: CGI Images (Larry Rosler)
    Re: Elegant substitution regex question <jglascoe@giss.nasa.gov>
    Re: Elegant substitution regex question <burton.not.spam@lucent.com>
    Re: flock() on NT? <techno@umbriel.demon.co.uk>
    Re: flock() on NT? (Michael Budash)
    Re: flock() on NT? <camerond@mail.uca.edu>
    Re: flock() on NT? (Michael Budash)
    Re: how to include a init table file without complainin <jglascoe@giss.nasa.gov>
        how to include a init table file without complaining fr (Tungning Cherng)
        Login, redirect, and who is the user? (Todd P.)
    Re: Multiple Users Corrupting File <cassell@mail.cor.epa.gov>
        Problem passing block and array reference to subroutine <boldts@korax.net>
        Problem with Method Calls / Packages <swett@ncats.net>
    Re: Problem with Method Calls / Packages (Dave Schenet)
    Re: Problem with Method Calls / Packages <ebohlman@netcom.com>
    Re: Problem with Method Calls / Packages <aghaeim@genesis.co.nz>
    Re: Pushing current line back onto <FILE> (Charles DeRykus)
    Re: Regex limits for regex/function calls within subsit <burton.not.spam@lucent.com>
        Send Form Data to the end of a URL within the HTML outp <shawncarpenter@MailAndNews.com>
    Re: Send Form Data to the end of a URL within the HTML  <che@debian.org>
    Re: The truth about the Pentium III chip and ID --- **b <jeff_kline@hopkins.k12.mn.us>
    Re: The truth about the Pentium III chip and ID --- **b (Stuart R. Fuller)
        Undefined subroutine error (John )
    Re: UNIQUE variable... (Bart Lateur)
    Re: Url validation question <greg2@surfaid.org>
    Re: Web Databases (Hakan Ardo)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: 16 Mar 1999 23:59:16 GMT
From: Dan Sugalski <sugalskd@netserve.ous.edu>
Subject: Re: 1000 thread limit?
Message-Id: <7cmr8k$7q8$2@news.NERO.NET>

archon16@my-dejanews.com wrote:
: First of all, I'd like to thank you, Dan, for giving me your excellent
: responses.  You've given me much food for thought and sent me researching
: thread pools and such.	I think I might be able to actually pull this off
: after all! Read on...

: In article <7chb6g$60e$1@news.NERO.NET>,
:   Dan Sugalski <sugalskd@netserve.ous.edu> wrote:
:> Using a thread pool would make scaling easier in some ways--set up a queue
:> that holds the connection info (pouring more into it if need be) and then
:> create a boatload of threads that each snag a record out of the queue and
:> Do The Right Thing with it. (Which may well be the approach you're
:> considering)

: I don't know much about thread pooling, but... is this what you had in mind?

I was thinking of thread pools in general, rather than Thread::Pool
specifically, though it's a good place to start.

:    use Thread::Pool;

:    sub doStuff($) {
:      # do some ... uh ... stuff.
:    }

:    my $pool = Thread::Pool->new(Max => -1);

:    foreach $address (@addresses) {
:      $pool->enqueue(\&doStuff, $address);
:    }

: Note that I set Max to -1, which supposedly means no limit on the pool size;
: will the Thread::Pool module then be smart enough to automatically detect the
: OS thread limit and stay just under it?

Thread::Pool isn't smart enough to stup just under the OS limit.
(Detecting the OS limit on all the platforms that support threading is
non-trivial, especially on systems like linux where the limit depends on
what other folks are doing too)

: Aside from that, my main concern with this method would be the overhead
: associated with creating and destroying millions of threads, potentially
: several thousand each second.

Thread::Pool's supposed to reuse threads, at least I think that's the
plan. (It's beta code, so it probably could stand some tweaking still)

: Whereas if I manage my own pool manually, I
: can re-use the same thread for multiple connections.  I can just have a
: static pool of 30K or so threads, such that each thread grabs pending
: addresses from a common pool and processes them in serial:

:   use Thread;

:   sub doStuff() {
:     while ($addr = getNextAvailableAddress()) {  # Use this one thread for
:       # do some stuff                              thousands of addresses!
:     }
:   }

:   while ($t = new Thread(\&doStuff)) {
:     push @pool, $t;
:   }

:   foreach $t (@pool) { $t->join() }

: (I can't think of any simple way to do this using Thread::Pool.)  Which method
: do you think is better?  Is the thread creation/destruction overhead really
: significant, or am I just complicating things trying to avoid it?

Using a fixed size thread pool that operate off a central queue (which is
what you've got here, essentially) is likely a better solution for your
problem. It's a touch less general than Thread::Pool, which means you skip
some of the overhead.

:> Just out of curiosity, how much longer does it take with
:> 1000 threads vs your current 30K version? (It's always possible that it
:> just doesn't matter, since you're bottlenecking other places)

: About thirty times longer.  There is no bandwidth bottleneck, because the
: vast majority of connection attempts fail (like, 99.9%), so the only
: bottleneck is OS resources!

Ah. I was thinking you were getting a higher hit rate, which would shift
the bottleneck.

: Well, at any rate ... a friend of mine is going to build his own web server
: and put it on an OC-3 connection (155Mbps).  I'm going to help him build the
: machine and choose an OS and software, etc, and I'll have free reign to run
: my program, but I don't want to hog all his system resources!  So now I have
: all sorts of options!  :-)  What OS should we choose, how do we configure
: mondo-thread capability, and how do I make my program play nice?

Well, personally I'd find a nice Alpha machine, throw OpenVMS on it, and
have at it. The OS has better management capabilities than Linux, and a
nice threading environment. That's likely a minority opinion, though (just
by a bit :).

If you want to go Unix, I'd shoot for either Digial Unix ('scuse me--Tru64
Unix) or Solaris. Going DU has the advantage that, as the hardware also
runs Linux, (ugh) NT, and possibly VMS (if you play your cards right),
you've got flexibility to change later. (I still think VMS is the way to
go, though)

					Dan


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

Date: Tue, 16 Mar 1999 17:10:36 -0500
From: "Rollo Lawson" <rollo@enter.net>
Subject: Can someone please help me with this counter script!
Message-Id: <36eed621@news3.enter.net>

I have been trying to get a simple counter work for about a week now and Iam
fed up can someone please help me.
My web server does not support server side includes,  so i have to use an
image tag to call the counter script.
EX. <img src="http:www.whatever.net/cgi-bin/counter.pl">
This works and everything and it calls the script and imcrements the count
file, but it leaves a picture of a broken image on the screen.  And that is
no good for a supposed webmaster like myself.  I would rather have it be a
hidden counter but you cannot hide a image called by an html <img tag.  Now
I have seen some scripts that send back an image to the page and it is
displayed instead of the broken image.    I have tried this but it does not
send the image back the image stays broken.  Below is the html code then the
script.  PLEASE SOMEONE HELP!!!!!!!!!!!!


HTML CODE
____________________________________________________________________________
________________

<HTML>
<BODY bgcolor="black" TEXT="#FFFFFF">
<CENTER>
<H1>WELCOME TO OPINION.COM</H1>
</CENTER>
<HR>
<P>
Who do you think will win the fight on Saturday and why.  All post will be
added to my guestboook.

<FORM METHOD="POST" ACTION="HTTP://207.16.152.171/cgi-bin/guest.pl">
<b>
FIRST NAME: <INPUT TYPE="TEXT" NAME="firstname" SIZE="25"><BR>
<br>
LAST NAME: <INPUT TYPE="TEXT" NAME="lastname" SIZE="25"><BR>
<BR><br>
WHO DO YOU THINK WILL WIN THE FIGHT ON SATURDAY BETWEEN EVANDER HOLYFIELD
AND
LENNOX LEWIS.  YOUR REPLIES WILL BE LEFT ON THE MESSAGE BOARD.
<br>
<textarea cols=45 rows=11 name="chochatext">
</textarea><BR><BR>
<P>
<INPUT TYPE="RESET" VALUE="CLEAR">
<INPUT TYPE="SUBMIT" NAME="SUBMIT" VALUE="ENTER">

</FORM>

<center><img src="http://rollo/cgi-bin/count.pl" </center>


</BODY>
</HTML>

____________________________________________________________________________
____________________

Perl code


!/perl/bin/perl
open(Count,"<remote.txt");
$total = <Count>;
close(Count);
$total++;
open(Count,">remote.txt");
print Count $total;
close(Count);
print "Content-Type: image/gif\n\n";
print "<img src=\"http://rollo/mirv.gif\">";

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

Help please!!!!!!


Rollo Lawson
rollo@enter.net

or rollo_lawson@yahoo.com







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

Date: 16 Mar 1999 22:26:55 GMT
From: hakan@hobbe.lub.lu.se (Hakan Ardo)
To: "Rollo Lawson" <rollo@enter.net>
Subject: Re: Can someone please help me with this counter script!
Message-Id: <7cmlrf$st4$2@news.lth.se>

In article <36eed621@news3.enter.net>,
	"Rollo Lawson" <rollo@enter.net> writes:

> print "Content-Type: image/gif\n\n";
> print "<img src=\"http://rollo/mirv.gif\">";

Here is you'r problem, this makes the browser think that the string 
"<img src=\"http://rollo/mirv.gif\">" is a gif image which it is not 
(it is html code). What you can do is have your script redirect the 
browser to the image by replacing those two lines with:

  print "Location: http://rollo/mirv.gif\n\n";

BTW: rollo dosn't seem to be a valid hostname, you should probably use 
you're full hostname in the url.

---------------------------------------------------------------
 Name:        Hakan Ardo
 E-Mail:      hakan@debian.org
 WWW:         http://www.ub2.lu.se/~hakan/sig.html
 Public Key:  Try "finger hakan@master.debian.org"
 Fingerprint: E9 81 FD 90 53 5C E9 3E  3D ED 57 15 1B 7E 29 F3
 Interests:   WWW, Programming, 3D graphics

 Thought for the day: As long as one understands, the
 spelling does not matter :-)
---------------------------------------------------------------


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

Date: Tue, 16 Mar 1999 17:42:23 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: Rollo Lawson <rollo@enter.net>
Subject: Re: Can someone please help me with this counter script!
Message-Id: <36EEDE4F.DB0D59B1@giss.nasa.gov>

[courtesy copy of post sent to cited author]

Rollo Lawson wrote:
> 

<SNIP!!!!!!>

> print "Content-Type: image/gif\n\n";
> print "<img src=\"http://rollo/mirv.gif\">";

these two lines don't make sense.  Try replacing the
second line with:

open FH, "< /absolute/path/to/image.gif";
print while <FH>;  # spit contents of image file to stdout

> Help please!!!!!!

	Narf!!!!!!
	Jay Glascoe
-- 
"'C' is for 'Cookie', that's good enough for me."
  --Cookie Monster


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

Date: Sat, 13 Mar 1999 09:39:14 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: CGI Images
Message-Id: <MPG.1154429e3c86adbf989738@nntp.hpl.hp.com>

In article <36E9A8A6.D8CEACB4@idt.net> on Fri, 12 Mar 1999 18:52:06 -
0500, James Tolley <jamesht@idt.net >says...
 ...
> $fh = param('file_upload');
> binmode($fh); # <-- use binmode
> open(NEW, "+>image.gif") or print "oops: $!" and exit;
> binmode(NEW);  # <-- use binmode
> while(<$fh>) {
>     print NEW $_;
> }

It is somewhat pointless to do line-at-a-time I/O on a file that doesn't 
have any 'lines'.

One could do it better as a loop on read/write or sysread/syswrite.  But 
if the file isn't too large to fit conveniently in memory (and what GIF 
file would be?), then I would do it in one operation:

  { local $/; print NEW <$fh> }

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


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

Date: Tue, 16 Mar 1999 16:51:12 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: Burton Kent <burton@lucent.com>
Subject: Re: Elegant substitution regex question
Message-Id: <36EED250.20C8DF91@giss.nasa.gov>

[courtesy copy of post sent to cited author]

Burton Kent wrote:
> 
> I'm looking for an elegant way to do the following two
> related substitutions. Everything I've thought up
> requires a hack of some sort.

my $string = do { undef local $/; <INFILE>; };
my @text_list = ();
push @text_list, $1 while ($string =~ m#<synopsis>(.*?)</synopsis>#gs);      

foreach (@text_list) { print "<indexterm>$_<indexterm>\n" }
print $string;

	Jay Glascoe
-- 
"Just say 'Narf!'."
  --Pinky


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

Date: Tue, 16 Mar 1999 17:03:34 -0600
From: Burton Kent <burton.not.spam@lucent.com>
Subject: Re: Elegant substitution regex question
Message-Id: <36EEE346.94E149F@lucent.com>

This looks like it should work.  Thanks, Reg.

$text =~ s%((?:<refsynopsisdiv>)?(.*?)(?:</refsynopsisdiv>)?)%
$all = $1;
$refsynopsis = $2;

while ( $refsynopsis =~ m#<synopsis[^>]*>(.*?)</synopsis>#g) {
       push @synopsis_list, $1;
}

my $out;
for $synopsis (@synopsis_list) {
        $out .=
"<indexterm><primary>\n<secondary>$synopsis</secondary>\n</indexterm"
}

$out .= $all;
$out;
%sg;

Burton


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

Date: Tue, 16 Mar 1999 17:17:29 -0500
From: "Techno" <techno@umbriel.demon.co.uk>
Subject: Re: flock() on NT?
Message-Id: <7cml9r$a4i0$1@newssvr04-int.news.prodigy.com>


Michael Budash wrote in message ...
>i'm pretty sure flock() won't work on nt systems... am i correct?
>
>so what do youz guys use in such dire (read that: micro$oft) predicaments?
>
>tia-
>--
>@-----------------------------@--------------------@
>| Michael Budash Consulting   | 707-255-5371       |
>| Perl, Javascript, Html      | 707-258-7800 x7736 |
>| Official Extropia Developer | mbudash@sonic.net  |
>@-----------------------------@--------------------@

flock() is working fine for me on NT (and HP-UX for that matter) - my only
problem is VMS ;)

I'm thinking about resorting to using LockFile::Simple's lock & unlock
instead - anybody got any comments on these ??

Techno.






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

Date: Tue, 16 Mar 1999 14:28:46 -0800
From: mbudash@trantracks.com (Michael Budash)
Subject: Re: flock() on NT?
Message-Id: <mbudash-1603991428460001@d26.nas1.napa.sonic.net>

In article <7cml9r$a4i0$1@newssvr04-int.news.prodigy.com>, "Techno"
<techno@umbriel.demon.co.uk> wrote:

>Michael Budash wrote in message ...
>>i'm pretty sure flock() won't work on nt systems... am i correct?
>>
>>so what do youz guys use in such dire (read that: micro$oft) predicaments?

>flock() is working fine for me on NT (and HP-UX for that matter) - my only
>problem is VMS ;)
>
>I'm thinking about resorting to using LockFile::Simple's lock & unlock
>instead - anybody got any comments on these ??
>

thanks - in the meantime i found that the mistake was mine...
-- 
@-----------------------------@--------------------@
| Michael Budash Consulting   | 707-255-5371       |
| Perl, Javascript, Html      | 707-258-7800 x7736 |
| Official Extropia Developer | mbudash@sonic.net  |
@-----------------------------@--------------------@


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

Date: Tue, 16 Mar 1999 16:41:10 -0600
From: Cameron Dorey <camerond@mail.uca.edu>
To: Michael Budash <mbudash@trantracks.com>
Subject: Re: flock() on NT?
Message-Id: <36EEDE06.5F38172E@mail.uca.edu>

[cc'd to mb]

Michael Budash wrote:
> 
> i'm pretty sure flock() won't work on nt systems... am i correct?

No.

> 
> so what do youz guys use in such dire (read that: micro$oft) predicaments?

I use flock().

Cameron Dorey
camerond@mail.uca.edu

(You might want to brush up on your Perl if you are going to advertize
yourself with the signature below. Your question is pretty basic.)

> tia-
> --
> @-----------------------------@--------------------@
> | Michael Budash Consulting   | 707-255-5371       |
> | Perl, Javascript, Html      | 707-258-7800 x7736 |
> | Official Extropia Developer | mbudash@sonic.net  |
> @-----------------------------@--------------------@


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

Date: Tue, 16 Mar 1999 15:21:50 -0800
From: mbudash@trantracks.com (Michael Budash)
Subject: Re: flock() on NT?
Message-Id: <mbudash-1603991521500001@d26.nas1.napa.sonic.net>

In article <36EEDE06.5F38172E@mail.uca.edu>, Cameron Dorey
<camerond@mail.uca.edu> wrote:

>[cc'd to mb]

no, it wasn't...

>Michael Budash wrote:
>> 
>> i'm pretty sure flock() won't work on nt systems... am i correct?
>
>No.
>

thanks - menatime i found out that the problem was not with flock(), but
with an improper installation of perl on my client's nt system...

>> 
>> so what do youz guys use in such dire (read that: micro$oft) predicaments?
>
>I use flock().
>

thanks

>Cameron Dorey
>camerond@mail.uca.edu
>
-- 
@-----------------------------@--------------------@
| Michael Budash Consulting   | 707-255-5371       |
| Perl, Javascript, Html      | 707-258-7800 x7736 |
| Official Extropia Developer | mbudash@sonic.net  |
@-----------------------------@--------------------@


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

Date: Tue, 16 Mar 1999 18:09:25 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: cherng@bbn.com
Subject: Re: how to include a init table file without complaining from "use  strict"
Message-Id: <36EEE4A4.7123DB37@giss.nasa.gov>

[courtesy copy of post sent to cited author]

hi Donnie,

On Tue, 16 Mar 1999 22:19:38, Tungning Cherng wrote:
> 
> use strict;
> my %largeTable=(
>    'a' , '1',
>    'b' , '2',
> );
> print "$largeTable{'a'}\n";

$ cat a.pm
%largeTable=(
   'a' , 'success',
   'b' , '2',
);

$ cat b.pl
use strict;
use vars qw(%largeTable);
use a;
print "$largeTable{'a'}\n";

$ perl b.pl
success

	Jay Glascoe
-- 
http://www.giss.nasa.gov/cgi-bin/csci/change.pl


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

Date: Tue, 16 Mar 1999 22:19:38 GMT
From: cherng@uuman.bbn.com (Tungning Cherng)
Subject: how to include a init table file without complaining from "use strict"
Message-Id: <YNAH2.278$p4.115121@burlma1-snr2>

The following file works file:
-------------
use strict;
my %largeTable=(
   'a' , '1',
   'b' , '2',
);
print "$largeTable{'a'}\n";
------------

However, I have a very large initialized table, would like to separate into
an individual file.  

For example, Two files: a.pl ad b.pl.

% cat a.pl
my %largeTable=(
   'a' , '1',
   'b' , '2',
);

% cat b.pl
use strict;
require "a.pl";
print "$largeTable{'a'}\n";

Now run "perl b.pl", I got an error:
    Global symbol "largeTable" requires explicit package name ...

I have to remove "use strict" line, and use global variable to make it work.
I don't think it is the right way.

Could some one tell me how to solve the problem by using "use strict"?
thanks,
Donnie 
cherng@bbn.com


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

Date: Tue, 16 Mar 1999 17:22:17 -0600
From: email@domain.com (Todd P.)
Subject: Login, redirect, and who is the user?
Message-Id: <email-1603991734330001@the-cure.adtran.com>

Im trying to get the user login information from Netscape Enterprise
server 3.5.1. What I would like to do is, after the person logs in, they
will be redirected to an specific area for them. I have tried the
environment variables remote_user, auth_type, and remote_ident, but I get
nothing. I have set the restriced areas up with the admin server that
comes with netscape....

Is there something that I am missing, do I need to set somthing up on the
server?

Pleas help...

Todd


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

Date: Tue, 16 Mar 1999 14:22:18 -0800
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: Multiple Users Corrupting File
Message-Id: <36EED99A.84AAA1B8@mail.cor.epa.gov>

Michael Yevdokimov wrote:
> 
> Could you send me an example of using flock in this situation? ;)

There are a host of examples in the Perl docs on your machine /
network.. or at least there should be.  Use the perldoc command.

perldoc -f flock
perldoc perlfaq5 (and then search for flock)

and if you're going to search the web for *good* scripts, I 
suggest you start at Randal Schwartz's website
  http://www.stonehenge.com/merlyn/
and look at the columns he has written (and reproduced there).

David
-- 
David L. Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Tue, 16 Mar 1999 23:54:29 GMT
From: Hans Boldt <boldts@korax.net>
Subject: Problem passing block and array reference to subroutine
Message-Id: <36EEEF20.22FAF333@korax.net>

Greetings!  I did try looking in the docs for an answer, but 
I'm stumped.  (Not hard, since I haven't been programming in
Perl for long.)  The following code works:

----------------
sub testing (&\@)
{
   my ($proc, $arr) = @_;
   print "@$arr\n";
   &$proc;
}

@array = ('a', 'b', 'c');
testing
{
   print "in testing\n";
}
@array;
----------------

The following doesn't, and I've tried all manner of variations.
I would prefer to be able to code the reference to the array
as the first parameter to the subroutine, but nothing I've 
tried works.  I'm using 5.004-6.  Any thoughts would be greatly 
appreciated.

----------------
sub testing (\@&)
{
   my ($arr, $proc) = @_;
   print "@$arr\n";
   &$proc;
}

@array = ('a', 'b', 'c');
testing \@array,
{
   print "in testing\n";
};
----------------

Cheers!  Hans
-- 
http://www.korax.net/~boldts/


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

Date: 16 Mar 1999 17:04:14 -0500
From: "Steve Swett" <swett@ncats.net>
Subject: Problem with Method Calls / Packages
Message-Id: <01be6ffc$d92b7c20$68e4b0c7@bcs.newaygo.mi.us>

Here's the script.  I've numbered the statements here for reference
purposes.

1.  #!/usr/bin/perl -w
2.  
3.  use diagnostics;
4.  use DBI;
5.  use CGI;
6.  
7.  
8.  # connect to the database:
9.  $dbh = DBI->connect('dbi:mSQL:bcs:localhost');
10. 
11.  # create a table:
12.  $sql="create table customers (custid char(4), custname char(40))";
13.  $sth=$dbh->prepare($sql);
14.  $sth->execute($sth);
15.  
16.  
17.  # disconnect from the database:
18.  $dbh->disconnect;

I receive the following error when I try to run it:
------------------------
Can't call method "prepare" on unblessed reference at ./crtcusttbl.cgi line
13 (
#1)

    (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 perlobj.  
-------------------------
Any suggestions?  Thanks.


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

Date: 16 Mar 1999 22:44:01 GMT
From: newsuser@spamtrap.shodan.net (Dave Schenet)
Subject: Re: Problem with Method Calls / Packages
Message-Id: <7cmmrh$20m$1@winter.news.rcn.net>

Steve Swett (swett@ncats.net) wrote:
: Here's the script.  I've numbered the statements here for reference
: purposes.
: 
: 1.  #!/usr/bin/perl -w
: 2.  
: 3.  use diagnostics;
: 4.  use DBI;
: 5.  use CGI;
: 6.  
: 7.  
: 8.  # connect to the database:
: 9.  $dbh = DBI->connect('dbi:mSQL:bcs:localhost');
: 10. 
: 11.  # create a table:
: 12.  $sql="create table customers (custid char(4), custname char(40))";
: 13.  $sth=$dbh->prepare($sql);
: 14.  $sth->execute($sth);
: 15.  
: 16.  
: 17.  # disconnect from the database:
: 18.  $dbh->disconnect;
: 
: I receive the following error when I try to run it:
: ------------------------
: Can't call method "prepare" on unblessed reference at ./crtcusttbl.cgi line
: 13 (
: #1)
: 

[snip]

: Any suggestions?  Thanks.

At line 10, you could check if $dbh is indeed an object.

if (! ref($dbh)) { die "Something failed with DBI->connect"; }

The manpage/docs for this package should have reasons why it would fail
to return an object.

--Dave
Dave Schenet - newsuser@spamtrap.shodan.net.
Getting my valid email address is a two step process.
First, delete spamtrap.  Second, replace newsuser with shodan.



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

Date: Tue, 16 Mar 1999 23:05:09 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Problem with Method Calls / Packages
Message-Id: <ebohlmanF8pMsL.IBu@netcom.com>

Steve Swett <swett@ncats.net> wrote:
: Here's the script.  I've numbered the statements here for reference
: purposes.

: 8.  # connect to the database:
: 9.  $dbh = DBI->connect('dbi:mSQL:bcs:localhost');

You never checked to see if the connection was successful.  If it wasn't,
$dbh isn't going to be an object reference and you'll get the error
message you got when you try to use it as if it were one (like calling 
methods through it).




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

Date: Wed, 17 Mar 1999 12:11:24 +1300
From: Meh <aghaeim@genesis.co.nz>
Subject: Re: Problem with Method Calls / Packages
Message-Id: <36EEE51C.E6217665@genesis.co.nz>

Steve Swett wrote:
> 
> Here's the script.  I've numbered the statements here for reference
> purposes.
> 
> 1.  #!/usr/bin/perl -w
> 2.
> 3.  use diagnostics;
> 4.  use DBI;
> 5.  use CGI;
> 6.
> 7.
> 8.  # connect to the database:
> 9.  $dbh = DBI->connect('dbi:mSQL:bcs:localhost');
> 10.
> 11.  # create a table:
> 12.  $sql="create table customers (custid char(4), custname char(40))";
> 13.  $sth=$dbh->prepare($sql);
> 14.  $sth->execute($sth);
> 15.
> 16.
> 17.  # disconnect from the database:
> 18.  $dbh->disconnect;
> 
> I receive the following error when I try to run it:
> ------------------------
> Can't call method "prepare" on unblessed reference at ./crtcusttbl.cgi line
> 13 (
> #1)
> 
>     (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 perlobj.
> -------------------------
> Any suggestions?  Thanks.


Here is the typical code I usually use:
(look at my first line, it is somewhat different to yours.It may be your
problem)

        my $dbh = DBI->connect("DBI:mSQL:sequencing", undef, undef);
        my $sth = $dbh->prepare("SELECT col1,col2 FROM table1 ");
        if (!$sth) {
                die "Error in preparing sth:" . $dbh->errstr . "\n";
        }
        if (!$sth->execute) {
                die "Error in executing sth:" . $sth->errstr . "\n";
        }
        my $rc = $sth->bind_columns(undef, \$cola, \$colb);
        while ($sth->fetch) {
                print " $cola $colb \n ";
        }
        $sth->finish;
        $dbh->disconnect;

You can check the error message in last line of 'error_log' .


---------------------------------------------------------------------
Protect privacy, boycott Intel PIII: http://www.bigbrotherinside.org
---------------------------------------------------------------------


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

Date: Tue, 16 Mar 1999 22:15:19 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Pushing current line back onto <FILE>
Message-Id: <F8pKHJ.94D@news.boeing.com>

In article <7cjvtp$lvu@dgs.dgsys.com>,
Jete Software Inc. <jete@dgs.dgsys.com> wrote:
>I need to push the current line back onto the <FILE> file handle
>
>open(FILE, "/tmp/junk") || die "Can't open /tmp/junk";
>
>while <<FILE>) {
>
>	if (something) {
>		push $_ back onto <FILE>;
>		last;
>	}
>}
>


Here's a possiblity:


package My_Handle;
use Symbol;

sub TIEHANDLE {
   my $class = shift;
   my $file = shift;
   my $fh = gensym;
   open($fh, $file) or die "Can't open $file: $!";
   bless { fh => $fh, pos =>[tell $fh]}, $class;
}


sub READLINE {
   my $self = shift;
   my $fh = $self->{fh};
   $_ = <$fh>;
   if (something) {   # push back  
       my $previous = pop @{$self->{pos}};
       seek($fh, $previous, 0)  or
       die "seek: can't seek to $previous\n";
   }
   my $current = tell $fh;
   push @{$self->{pos}}, $current;
   return $_;
}

package main;
my $tied = tie  *MYFILE, 'My_Handle', '/tmp/junk' or
   die "can't tie: $!\n";
while (<MYFILE>) {
     ....
}
 ...



hth,
--
Charles DeRykus


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

Date: Tue, 16 Mar 1999 17:34:10 -0600
From: Burton Kent <burton.not.spam@lucent.com>
To: Ilya Zakharevich <ilya@math.ohio-state.edu>
Subject: Re: Regex limits for regex/function calls within subsitutions?
Message-Id: <36EEEA72.71ADE277@lucent.com>

How would you increase the available stack size?
What ways are there to get around this?

Burton
(please remove the .not.spam from my email address
to respond)

Ilya Zakharevich wrote:
> 
> [A complimentary Cc of this posting was sent to Ala Qumsieh
> <aqumsieh@matrox.com>],
> who wrote in article <x3yemmp8fl2.fsf@tigre.matrox.com>:
> >
> > Burton Kent <burton.not.spam@lucent.com> writes:
> >
> > > What kind of limits does Perl have on substitutions?
> >
> > what do you mean? You can substitute whatever you want, as many times
> > as you want.
> 
> > I have *NEVER* seen Perl give a "segmentation fault". Do you get any
> > error messages? Does Perl dump core?
> 
> Then you did not try hard enough.  Perl has a limit for "hard" sub-REx
> repetitions.  Unfortunately, this limit is dictated by the available
> stack size.
> 
> At compile time Perl tries to determine a reasonable limit:
> 
>   > perl -ce '/(a|bb){123456}/'
>   /(a|bb){123456}/: Quantifier in {,} bigger than 32766
> 
> but this is only a heuristic, and it is always possible to create a
> REx which would blow things away:
> 
>   > perl -we '$_ = "a" x 1e6; /(a?a?a?){12345}/'
>   Segmentation fault (core dumped)
> 
> Ilya


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

Date: Tue, 16 Mar 1999 23:28:20 GMT
From: Shawn Carpenter <shawncarpenter@MailAndNews.com>
Subject: Send Form Data to the end of a URL within the HTML output
Message-Id: <oOBH2.200$y26.245636@client.news.psi.net>

I would like to set up a form with in an HTML file  that would allow users 
to 
enter a stock symbol like MSFT and then execute a script that would send 
MSFT 
to the end of several URL's in the HTML output file.

Similiar to this http://www.dailystocks.com



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

Date: 16 Mar 1999 15:31:32 -0800
From: Ben Gertzfield <che@debian.org>
Subject: Re: Send Form Data to the end of a URL within the HTML output
Message-Id: <yttr9qpj9kb.fsf@gilgamesh.cse.ucsc.edu>

>>>>> "Shawn" == Shawn Carpenter <shawncarpenter@MailAndNews.com> writes:

    Shawn> I would like to set up a form with in an HTML file that
    Shawn> would allow users to enter a stock symbol like MSFT and
    Shawn> then execute a script that would send MSFT to the end of
    Shawn> several URL's in the HTML output file.

Great! Go to it.

Ben

-- 
Brought to you by the letters T and N and the number 8.
"Ooh, don't touch him, HE'S got the wall sconses."
Debian GNU/Linux maintainer of Gimp and GTK+ -- http://www.debian.org/
I'm on FurryMUCK as Che, and EFNet/Open Projects IRC as Che_Fox.


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

Date: Tue, 16 Mar 1999 12:38:52 -0600
From: "Jeffrey S. Kline" <jeff_kline@hopkins.k12.mn.us>
Subject: Re: The truth about the Pentium III chip and ID --- **boycott info**
Message-Id: <7cm86l$mrs$1@thor.ties.k12.mn.us>

I just have to step on this one a moment...

Where did you learn computers??? Do you know what "hostid" is really, and
its use and implications??? Do you know about demons, zones, and domains????
I have one of probably 1628904823e4 host ID's on my server only because I
use the same IP as the ones stated in 3 different RFC's about internal
private networks...

Is this over your head yet???

You cannot identify my boxes, any of them, from any of the rest of them out
there in the world. Then there's the story about "Dynamic" IP's which opens
the doors and windows some more on this.... Wanna keep going with this??!!!

The Intel thing is a whole different bag of worms entirely.

Jeff

Greg Gershowitz wrote in message <36ee69a8.992557692@news.vnet.net>...
>
>Someone tell my why this is such a big deal?  Every unix box in
>existance has a unique ID.  It's the hostid.  What's it for?
>Licensing, mostly.  Of course unix licensing is far more mature than
>for windows.  Heck, even a 486 can be made to cough up a hostid.  Of
>course, I don't know of any cases where that hostid get transmitted to
>a vendor, but what's to stop it from happening?
>
>-Greg G
>
>--
>-Greg "TORCHA" Gershowitz
>-DG3X's own Extreme Icon
>To Reply: See the organization line
>Spam sucks.  Fuck you spammers.  Have a Nice Day.
>http://www.geocities.com/Area51/5207




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

Date: Tue, 16 Mar 1999 23:00:03 GMT
From: stu@c49395-a.wodhvn1.mi.home.com (Stuart R. Fuller)
Subject: Re: The truth about the Pentium III chip and ID --- **boycott info**
Message-Id: <oi9mc7.ss3.ln@localhost>

Greg Gershowitz (root@aol.com) wrote:
: 
: Someone tell my why this is such a big deal?  Every unix box in
: existance has a unique ID.  It's the hostid.  

Well, there's a command called "hostid", and it makes a function call to
"sethostid" and/or "gethostid".  However, it is not required that they return
unique values.  For example, my Linux box (Cyrix processor) returns a number
that converts back to my IP address.  That IP address may vary from time to
time.  Some Digital UNIX boxes I just tried all return 0 for hostid.  Some Sun
boxes return unique (at least unique between the few I looked at) values, and
they are not related to the IP address.  However, the Sun boxes do not
constitute "every unix box in existance[sic]".

        Stu


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

Date: Tue, 16 Mar 1999 23:47:16 GMT
From: John@melon17.freeserve.co.uk (John )
Subject: Undefined subroutine error
Message-Id: <36eeeccf.20744045@news.freeserve.net>

I run a perl script via a cgi with no real problem.

When i run it from a cronjob i get undefined sub-routine
error.

Does anyone know why i might be getting this ?

john



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

Date: Tue, 16 Mar 1999 23:29:00 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: UNIQUE variable...
Message-Id: <36efe5da.719242@news.skynet.be>

Steve Wells wrote:

>This sounds exactly like Amazon.com.  Every page on their site is dynamic
>and the Unique ID is appended to every url as it is passed back from the
>server.  It also sounds like a lot of work unless you use the 
>Apache::Registry and the HTML::Parser routines ;-)  

Actually it's not that difficult. You have a main script that acts like
the server. The extra path info can be used as some sort of directory
path (it may contain slashes), which tells the server scripts which page
to generate; those can be based on a HTML "template" (actually a
reasonably valid HTML file). Inserting the unique ID into the URL's:
that's just a matter of interpolating: replacing a variable's name in
the original HTML "templates" by it's value. It's really quite simple.

>Just to clarify the environment variable is called PATH_INFO as opposed 
>to EXTRA_PATH (at least that's what it in apache).

I can just say one thing: "oops".

	Bart.


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

Date: Tue, 16 Mar 1999 23:45:30 +0000
From: Greg Griffiths <greg2@surfaid.org>
To: John@melon17.freeserve.co.uk
Subject: Re: Url validation question
Message-Id: <36EEED1A.B30487F2@surfaid.org>

has been recently answered in the group

John wrote:
> 
> Is it possible when validating
> an url to get the validated result into
> a scalar.
> 
> Example:
> ----------------------------------------------------------
> get ($url) error returns $vaild='no'
> get ($url)  success returns $vaild='yes'
> -----------------------------------------------------------
> 
> John


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

Date: 16 Mar 1999 22:21:11 GMT
From: hakan@hobbe.lub.lu.se (Hakan Ardo)
To: Jeff Doak <jdoak@MailAndNews.com>
Subject: Re: Web Databases
Message-Id: <7cmlgn$st4$1@news.lth.se>

On Sat, 13 Mar 1999 08:41:47 -0500, Jeff Doak wrote:
> I am creating a web site, and I want to add an interactive database.  
> One that users can add/change/delete records.  Can I do that using 
> Perl, and is there a good book to tell me how it's done?

Sure you can! Take a look at DBIx::HTMLView, is a perl package
designed to do just that using an DBI database (such as mSQL) as
database engine. It's availibel in CPAN as:

  authors/id/H/HA/HAKANARDO/DBIx-HTMLView-0.4.tar.gz

Any good books I don't have but the HTMLView package should contain
enough docs to get you started. If not, please mail me and we'll sort
out the details.

-- 
---------------------------------------------------------------
 Name:        Hakan Ardo
 E-Mail:      hakan@debian.org
 WWW:         http://www.ub2.lu.se/~hakan/sig.html
 Public Key:  Try "finger hakan@master.debian.org"
 Fingerprint: E9 81 FD 90 53 5C E9 3E  3D ED 57 15 1B 7E 29 F3
 Interests:   WWW, Programming, 3D graphics

 Thought for the day: As long as one understands, the
 spelling does not matter :-)
---------------------------------------------------------------


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

Date: 12 Dec 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 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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