[21868] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4072 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 6 14:08:03 2002

Date: Wed, 6 Nov 2002 11:05:14 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 6 Nov 2002     Volume: 10 Number: 4072

Today's topics:
    Re: a perl poem <jim.bloggs@eudoramail.com>
    Re: a perl poem <usenet@dwall.fastmail.fm>
    Re: a perl poem <usenet@dwall.fastmail.fm>
    Re: a perl poem (Tad McClellan)
    Re: A vision for Parrot (Paul Boddie)
    Re: A vision for Parrot (Walter Roberson)
    Re: A vision for Parrot <dnew@san.rr.com>
    Re: A vision for Parrot <robin@jessikat.fsnet.co.uk>
    Re: A vision for Parrot <graham.lee@wadham.ox.ac.uk>
    Re: A vision for Parrot <akuchlin@ute.mems-exchange.org>
    Re: A vision for Parrot <robin@jessikat.fsnet.co.uk>
    Re: Any Experience with Embedded Perl/HTML? (darryl)
    Re: defaults in packages <ubl@schaffhausen.de>
    Re: Do scripts use the CPU while sleeping? (Jonathan Lonsdale)
        file order in opendir DH <chris.harris@cwfi.co.fk>
    Re: How much faster is dbm over MySQL <djf@gxn.net>
        How to correctly use AUTOLOAD in derived class? <kevin@wx3.com>
        How to guarantee process ID stays with web connection <joe@amrita.net>
    Re: How to guarantee process ID stays with web connecti <fxn@hashref.com>
    Re: Is it wrong to store method definitions in a databa (Phil Brodd)
    Re: Net::FTP how can I change directory? <bart.lateur@pandora.be>
    Re: Net::FTP how can I change directory? (Jim McCallum)
        param($var).  <todd@mrnoitall.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 6 Nov 2002 14:34:19 -0000
From: "doofus" <jim.bloggs@eudoramail.com>
Subject: Re: a perl poem
Message-Id: <aqb99d$8bg83$1@ID-150435.news.dfncis.de>

zzapper wrote:
> On Wed, 6 Nov 2002 09:56:49 GMT, Daniel Novotny
> <xnovotn3@informatics.muni.cz> wrote:
>
>> die if defined undef;
>> die ("ouch!") if not exists $meaning_of{life};
>> kill time;
>> do { not kill caller } if "phone rings";
>
> 2b||!2b?

LOL. If you could find some way of saying 'that is the question' I'd be
very happy. How about entire of Hamlet for perl lovers...;)




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

Date: Wed, 06 Nov 2002 16:42:57 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: a perl poem
Message-Id: <Xns92BE772E29650dkwwashere@216.168.3.30>

doofus <jim.bloggs@eudoramail.com> wrote on 06 Nov 2002:

> zzapper wrote:
>> On Wed, 6 Nov 2002 09:56:49 GMT, Daniel Novotny
>> <xnovotn3@informatics.muni.cz> wrote:
>>
>>> die if defined undef;
>>> die ("ouch!") if not exists $meaning_of{life};
>>> kill time;
>>> do { not kill caller } if "phone rings";
>>
>> 2b||!2b?
> 
> LOL. If you could find some way of saying 'that is the question' I'd be
> very happy. How about entire of Hamlet for perl lovers...;)

package that;
@ISA = qw(question);
my $whether = 'better';
suffer(outrageous_fortune->( ['slings', 'arrows'] ) || oppose();
sub oppose { exit; }

-- 
David K. Wall - usenet@dwall.fastmail.fm
"Oook."


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

Date: Wed, 06 Nov 2002 16:46:03 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: a perl poem
Message-Id: <Xns92BE77B4B2D39dkwwashere@216.168.3.30>

David K. Wall <usenet@dwall.fastmail.fm> wrote on 06 Nov 2002:

> doofus <jim.bloggs@eudoramail.com> wrote on 06 Nov 2002:
> 
>> zzapper wrote:
>>> On Wed, 6 Nov 2002 09:56:49 GMT, Daniel Novotny
>>> <xnovotn3@informatics.muni.cz> wrote:
>>>
>>>> die if defined undef;
>>>> die ("ouch!") if not exists $meaning_of{life};
>>>> kill time;
>>>> do { not kill caller } if "phone rings";
>>>
>>> 2b||!2b?
>> 
>> LOL. If you could find some way of saying 'that is the question' I'd be
>> very happy. How about entire of Hamlet for perl lovers...;)
> 
> package that;
> @ISA = qw(question);
> my $whether = 'better';
> suffer(outrageous_fortune->( ['slings', 'arrows'] ) || oppose();

Oops, left out a paren.

suffer(outrageous_fortune->( ['slings', 'arrows'] )) || oppose();

:-)

> sub oppose { exit; }
 

-- 
David K. Wall - usenet@dwall.fastmail.fm
"Oook."


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

Date: Wed, 6 Nov 2002 11:25:01 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: a perl poem
Message-Id: <slrnasik3d.bb8.tadmc@magna.augustmail.com>

zzapper <zzapper@ntlworld.com> wrote:

> 2b||!2b?


   Message-Id: <slrna5l59o.7h9.tadmc@tadmc26.august.net>


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


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

Date: 6 Nov 2002 07:23:38 -0800
From: paul@boddie.net (Paul Boddie)
Subject: Re: A vision for Parrot
Message-Id: <23891c90.0211060723.22fd36bc@posting.google.com>

Robin Becker <robin@jessikat.fsnet.co.uk> wrote in message news:<3pE8dhAtvNy9EwoQ@jessikat.fsnet.co.uk>...
> 
> it seems that only those with sufficient muscle can force this on the
> world eg Sun/IBM/M$. They can clearly see the need to support only one
> backend. 

 ...each. ;-)

Well, I suppose Sun and IBM are sort of sharing.

Paul

P.S. Projects like Parrot only really tend to succeed if they either
produce results quickly enough for casually interested parties or have
enough direction and motivation for the prolonged period of time that
they aren't producing highly usable output. Despite hearing about
Parrot occasionally, I'm not so sure that Parrot exhibits either of
these properties, but it would be nice to be proved wrong.


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

Date: 6 Nov 2002 15:59:28 GMT
From: roberson@ibd.nrc.ca (Walter Roberson)
Subject: Re: A vision for Parrot
Message-Id: <aqbe90$85d$1@canopus.cc.umanitoba.ca>

In article <aqa2oa$8o1$1@news.ox.ac.uk>, Frodo Morris  <""> wrote:
:Imagine if parrot could understand all interpreted code.

I would have to think for a bit to come up with a proof, but
it seems fairly likely to me that that would be impossible.

At the very least, for it to be possible, you would have to
program indefinite-length pointers and allow all available disk
space to be used as extended memory.

The problem that people keep forgetting is that Turing Equivilence
requires indefinite memory. Turing Machines are defined as having
infinite "tapes". Given any finite memory size, I can come up with
an interpreter the emulation of which would not fit in that finite
memory size.
--
Would you buy a used bit from this man??


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

Date: Wed, 06 Nov 2002 16:31:10 GMT
From: Darren New <dnew@san.rr.com>
Subject: Re: A vision for Parrot
Message-Id: <3DC943CF.84A68F32@san.rr.com>

Robin Becker wrote:
> Funnily enough they kept telling me that as soon as I switched to
> F99/C++ etc etc that everything would be portable.

Your confusion is in thinking that "portable" is a binary value. Fortran
was certainly more portable than assembler, as was C. Tcl is certainly
more portable than Fortran or C. 

The other problem, of course, is that people keep improving their
capabilities, so what was portable is no longer adequate. Fortran is
quite portable, as long as you don't want to do 3D graphics driven by a
data glove.

As long as you don't want to do development in multiple languages or
dynamically load code safely over the net into some other OS process,
Tcl and Python are pretty good choices. Otherwise, you might want to
consider C# or Java. 

See how it works? :-)


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

Date: Wed, 6 Nov 2002 16:40:57 +0000
From: Robin Becker <robin@jessikat.fsnet.co.uk>
Subject: Re: A vision for Parrot
Message-Id: <Aw5hLiAZYUy9Ewe1@jessikat.demon.co.uk>

In article <3DC943CF.84A68F32@san.rr.com>, Darren New <dnew@san.rr.com>
writes
>Robin Becker wrote:
>> Funnily enough they kept telling me that as soon as I switched to
>> F99/C++ etc etc that everything would be portable.
>
>Your confusion is in thinking that "portable" is a binary value. Fortran
>was certainly more portable than assembler, as was C. Tcl is certainly
>more portable than Fortran or C. 
>
>The other problem, of course, is that people keep improving their
>capabilities, so what was portable is no longer adequate. Fortran is
>quite portable, as long as you don't want to do 3D graphics driven by a
>data glove.
>
>As long as you don't want to do development in multiple languages or
>dynamically load code safely over the net into some other OS process,
>Tcl and Python are pretty good choices. Otherwise, you might want to
>consider C# or Java. 
>
>See how it works? :-)
yes you claim to have a better mousetrap :) and suddenly ther are
1.5.2/2.0/2.1/2.2/2.3a1 versions of Python and 6.4/7.1....8.4 of Tcl and
I must buy the right C compiler or OS or things don't really quite port
oh well there you go.

English was portable until everyone started using it ;)
-- 
Robin Becker


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

Date: Wed, 06 Nov 2002 17:16:34 +0000
From: Frodo Morris <graham.lee@wadham.ox.ac.uk>
Subject: Re: A vision for Parrot
Message-Id: <aqbimo$a36$1@news.ox.ac.uk>

Walter Roberson wrote:
> In article <aqa2oa$8o1$1@news.ox.ac.uk>, Frodo Morris  <""> wrote:
> :Imagine if parrot could understand all interpreted code.
> 
> I would have to think for a bit to come up with a proof, but
> it seems fairly likely to me that that would be impossible.
> 
> At the very least, for it to be possible, you would have to
> program indefinite-length pointers and allow all available disk
> space to be used as extended memory.
> 
> The problem that people keep forgetting is that Turing Equivilence
> requires indefinite memory. Turing Machines are defined as having
> infinite "tapes". Given any finite memory size, I can come up with
> an interpreter the emulation of which would not fit in that finite
> memory size.
Perdantick bast.  :-)
Imagine if parrot could understand all currently- and popularly- 
implemented interpreted languages.

-- 
FM



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

Date: 06 Nov 2002 17:46:09 GMT
From: "A.M. Kuchling" <akuchlin@ute.mems-exchange.org>
Subject: Re: A vision for Parrot
Message-Id: <slrnasilb1.201.akuchlin@ute.mems-exchange.org>

In article <3DC8CDDD.7050103@mindspring.com>,
	Andrew Dalke wrote:
> It didn't happen.  Writing those translators are hard because each
> of the languages has different object models, which must be implemented
> nearly perfectly.  Guile is a full-fledge language built on years of

There's also the problem of motivation: who's going to write those
translators?  

    Tcl and Python programmers?  They have nicely usable
    implementations already.  Translation to Guile would buy them
    nothing, except for having to rewrite every single C extension.

    Guile programmers?  If they're Guile programmers, they must like 
    programming in Scheme.  Why would they work on translators for languages
    they'll never use?

A Guile programmer might write a Python translator out of pure
bloody-minded evangelism, of course, but it would require supernatural
determination to continue *maintaining* it for the long-term, and
there would still be the risk that the outside community would look at
the translator and ignore it, saying (it's too slow | it doesn't run
extension X that I really need | Guile doesn't run on my platform).
Similar arguments can applied to translators to Parrot, of course.

--amk                                                             (www.amk.ca)
ABBESS: In food, in sport, and life-preserving rest 
 To be disturbed would mad man or beast.
      -- _The Comedy of Errors_, V, i


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

Date: Wed, 6 Nov 2002 18:43:47 +0000
From: Robin Becker <robin@jessikat.fsnet.co.uk>
Subject: Re: A vision for Parrot
Message-Id: <eSXGjVAjLWy9Eweq@jessikat.demon.co.uk>

In article <aqbimo$a36$1@news.ox.ac.uk>, Frodo Morris 
 .
 .....
>> The problem that people keep forgetting is that Turing Equivilence
>> requires indefinite memory. Turing Machines are defined as having
>> infinite "tapes". Given any finite memory size, I can come up with
>> an interpreter the emulation of which would not fit in that finite
>> memory size.
>Perdantick bast.  :-)
>Imagine if parrot could understand all currently- and popularly- 
>implemented interpreted languages.
>
which language was it that got kicked to death by the others?
-- 
Robin Becker


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

Date: 6 Nov 2002 07:31:18 -0800
From: dfdyck@yahoo.com (darryl)
Subject: Re: Any Experience with Embedded Perl/HTML?
Message-Id: <da6cdb12.0211060731.7508553f@posting.google.com>

"F. Xavier Noria" <fxn@hashref.com> wrote in message news:<aqafho$ner$2@news.ya.com>...

> Have a look at this comparative:
> 
>    http://www.perl.com/pub/a/2001/08/21/templating.html
> 
> -- fxn

Great help...ty

Darryl


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

Date: Wed, 06 Nov 2002 16:17:05 +0100
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: defaults in packages
Message-Id: <aqbf3r$5lm$1@news.dtag.de>

Garry Williams wrote:

> Perhaps a better style would be: 
> 
>     # set/get class attribute SOME_VAR
>     sub SOME_VAR {
>       $SOME_VAR = $_[1] if $_[1];

What if 0 or undef are valid values?

->malte

-- 
srand 108641088; print chr int rand 256 for qw<J A P H>



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

Date: 6 Nov 2002 06:41:51 -0800
From: jon3001@hotmail.com (Jonathan Lonsdale)
Subject: Re: Do scripts use the CPU while sleeping?
Message-Id: <5a2621be.0211060641.4ff183d6@posting.google.com>

Benjamin Goldberg <goldbb2@earthlink.net> wrote in message news:<3DC8C2DE.3A667C6D@earthlink.net>...
> Hobo wrote:
> > 
> > I have a script I use to let visitors mail the URL to a friend with a
> > short message they include. 

<SNIP>

> None -- but that doesn't matter, since an attacker can make multiple
> connections to your web browser simultaneously, so you've got many
> instances of your script running... the 60 second sleep has very little
> effect at stopping spammers from taking advantage of it, except that it
> will annoy legitimate users of your program, and if your machine is
> attacked, it will use more resources on your computer.

I'm wondering how people usually approach this for email-a-friend type
services. A script I've got in development does this:

1. When the page is requested generates a hash of the client's IP and
user-agent. Embeds this in a hidden field.
2. When the page is submitted the integrity of the hash is checked.
3. Requests are logged to a MySQL database by IP and date/time.
4. Requests fail if:
A) a previous one was issued from the same IP less than 3 seconds ago
or
B) more than 50 requests issued from the IP in a day.

How effective is this and what further improvements could be added
without compromising the functions useabilty?


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

Date: Wed, 6 Nov 2002 15:14:42 -0300
From: "Chris Harris" <chris.harris@cwfi.co.fk>
Subject: file order in opendir DH
Message-Id: <aqbm8k$87a3h$1@ID-134007.news.dfncis.de>

I have a script that writes a webpage that displays a directory of thumbnail
images that are archived from a webcam. It works, however it is important
that the images are displayed in chronological order and for some reason
this isn't happening. The script is run as cronjob hourly and for some
reason new images occasionally appear amongst the old ones instead of adding
onto the end.

The file names are in the format dd-hh-mm.jpg

I have included the fragment of code below, and below that is an example of
the output.

Anybody any ideas on what is going wrong and how to sort it out,, or should
that be sort the output?

Cheers
Chris

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

# Now print the HTML page
#
open O, ">images/webcam/webcamindex.html";
print O <<EndPrint;
<H3>Archived Images</H3>
<p>Click the images to open the full size version in a new window.</p>

EndPrint
    my $file;
my $dir = "images/webcam";
opendir DH, $dir or die "Cannot open $dir: $!";
foreach $file (readdir DH) {
    next unless $file =~ /\.jpg$/;
        print O qq(<A href="/images/webcam/$file" target="Image Viewer"><img
src
="images/webcam/thumbs/$file" style="border: black solid 1px;"
alt="thumbnail $f
ile"></a>&nbsp;\n);
    }
closedir DH;

print O "</body></html>";

-----------------------
Output from the code. You can see files starting with 06 mixed in amongst
the ones starting with 05.
----------------------

<div style="width: auto; float: none; margin: 0.5em 0% 0.5em 28%;">
 <H3>Archived Images</H3>
<p>Click the images to open the full size version in a new window.</p>

<A href="/images/webcam/06-11-00.jpg" target="Image Viewer"><img
src="images/webcam/thumbs/06-11-00.jpg" style="border: black solid 1px;"
alt="thumbnail 06-11-00.jpg"></a>&nbsp;
<A href="/images/webcam/06-12-00.jpg" target="Image Viewer"><img
src="images/webcam/thumbs/06-12-00.jpg" style="border: black solid 1px;"
alt="thumbnail 06-12-00.jpg"></a>&nbsp;
<A href="/images/webcam/06-13-00.jpg" target="Image Viewer"><img
src="images/webcam/thumbs/06-13-00.jpg" style="border: black solid 1px;"
alt="thumbnail 06-13-00.jpg"></a>&nbsp;
<A href="/images/webcam/05-13-00.jpg" target="Image Viewer"><img
src="images/webcam/thumbs/05-13-00.jpg" style="border: black solid 1px;"
alt="thumbnail 05-13-00.jpg"></a>&nbsp;
<A href="/images/webcam/06-09-00.jpg" target="Image Viewer"><img
src="images/webcam/thumbs/06-09-00.jpg" style="border: black solid 1px;"
alt="thumbnail 06-09-00.jpg"></a>&nbsp;
<A href="/images/webcam/05-14-00.jpg" target="Image Viewer"><img
src="images/webcam/thumbs/05-14-00.jpg" style="border: black solid 1px;"
alt="thumbnail 05-14-00.jpg"></a>&nbsp;
<A href="/images/webcam/05-15-00.jpg" target="Image Viewer"><img
src="images/webcam/thumbs/05-15-00.jpg" style="border: black solid 1px;"
alt="thumbnail 05-15-00.jpg"></a>&nbsp;
<A href="/images/webcam/05-16-00.jpg" target="Image Viewer"><img
src="images/webcam/thumbs/05-16-00.jpg" style="border: black solid 1px;"
alt="thumbnail 05-16-00.jpg"></a>&nbsp;
<A href="/images/webcam/05-17-00.jpg" target="Image Viewer"><img
src="images/webcam/thumbs/05-17-00.jpg" style="border: black solid 1px;"
alt="thumbnail 05-17-00.jpg"></a>&nbsp;
<A href="/images/webcam/06-10-00.jpg" target="Image Viewer"><img
src="images/webcam/thumbs/06-10-00.jpg" style="border: black solid 1px;"
alt="thumbnail 06-10-00.jpg"></a>&nbsp;
<A href="/images/webcam/05-18-00.jpg" target="Image Viewer"><img
src="images/webcam/thumbs/05-18-00.jpg" style="border: black solid 1px;"
alt="thumbnail 05-18-00.jpg"></a>&nbsp;
<A href="/images/webcam/05-19-00.jpg" target="Image Viewer"><img
src="images/webcam/thumbs/05-19-00.jpg" style="border: black solid 1px;"
alt="thumbnail 05-19-00.jpg"></a>&nbsp;
<A href="/images/webcam/05-20-00.jpg" target="Image Viewer"><img
src="images/webcam/thumbs/05-20-00.jpg" style="border: black solid 1px;"
alt="thumbnail 05-20-00.jpg"></a>&nbsp;
<A href="/images/webcam/05-21-00.jpg" target="Image Viewer"><img
src="images/webcam/thumbs/05-21-00.jpg" style="border: black solid 1px;"
alt="thumbnail 05-21-00.jpg"></a>&nbsp;
<A href="/images/webcam/05-22-00.jpg" target="Image Viewer"><img
src="images/webcam/thumbs/05-22-00.jpg" style="border: black solid 1px;"
alt="thumbnail 05-22-00.jpg"></a>&nbsp;
<A href="/images/webcam/05-23-00.jpg" target="Image Viewer"><img
src="images/webcam/thumbs/05-23-00.jpg" style="border: black solid 1px;"
alt="thumbnail 05-23-00.jpg"></a>&nbsp;
<A href="/images/webcam/06-00-00.jpg" target="Image Viewer"><img
src="images/webcam/thumbs/06-00-00.jpg" style="border: black solid 1px;"
alt="thumbnail 06-00-00.jpg"></a>&nbsp;
<A href="/images/webcam/06-01-00.jpg" target="Image Viewer"><img
src="images/webcam/thumbs/06-01-00.jpg" style="border: black solid 1px;"
alt="thumbnail 06-01-00.jpg"></a>&nbsp;
<A href="/images/webcam/06-02-00.jpg" target="Image Viewer"><img
src="images/webcam/thumbs/06-02-00.jpg" style="border: black solid 1px;"
alt="thumbnail 06-02-00.jpg"></a>&nbsp;
<A href="/images/webcam/06-03-00.jpg" target="Image Viewer"><img
src="images/webcam/thumbs/06-03-00.jpg" style="border: black solid 1px;"
alt="thumbnail 06-03-00.jpg"></a>&nbsp;
<A href="/images/webcam/06-04-00.jpg" target="Image Viewer"><img
src="images/webcam/thumbs/06-04-00.jpg" style="border: black solid 1px;"
alt="thumbnail 06-04-00.jpg"></a>&nbsp;
<A href="/images/webcam/06-05-00.jpg" target="Image Viewer"><img
src="images/webcam/thumbs/06-05-00.jpg" style="border: black solid 1px;"
alt="thumbnail 06-05-00.jpg"></a>&nbsp;
<A href="/images/webcam/06-06-00.jpg" target="Image Viewer"><img
src="images/webcam/thumbs/06-06-00.jpg" style="border: black solid 1px;"
alt="thumbnail 06-06-00.jpg"></a>&nbsp;
<A href="/images/webcam/06-07-00.jpg" target="Image Viewer"><img
src="images/webcam/thumbs/06-07-00.jpg" style="border: black solid 1px;"
alt="thumbnail 06-07-00.jpg"></a>&nbsp;
<A href="/images/webcam/06-08-00.jpg" target="Image Viewer"><img
src="images/webcam/thumbs/06-08-00.jpg" style="border: black solid 1px;"
alt="thumbnail 06-08-00.jpg"></a>&nbsp;
</body></html>






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

Date: Wed, 6 Nov 2002 17:14:14 -0000
From: "djf" <djf@gxn.net>
Subject: Re: How much faster is dbm over MySQL
Message-Id: <usijblcs3s5u5d@corp.supernews.com>

dbm's are not a relational database - merely a key/value type storage.
Hence are much faster - but obviously not as functional

I suppose if you was to have said dbm/hash style it might have been remotely
OT, but hey

djf

"Hobo" <myusenetclient@requiresthis.com> wrote in message
news:myusenetclient-0611020407460001@63-93-75-203.lsan.cwia.com...
>
>
> (Apologies if this is OT)
>
> I often read that the various key-value databases you use with dbmopen are
> faster than MySQL, but have never seen anything quantifiable. Exactly how
> much faster? A rough estimate in some form other than "very" would be
> appreciated. Also, what is the largest value I can enter using dbmopen on
> whatever vesion of dbm Red Hat uses? Also, what version of dbm does Red
> Hat use? I want to do simple key-value retrieval with large values ranging
> from 10-20K, would I be better off with MySQL?
>
>
>
> TIA




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

Date: Wed, 06 Nov 2002 18:23:26 GMT
From: "Kevin Lin" <kevin@wx3.com>
Subject: How to correctly use AUTOLOAD in derived class?
Message-Id: <y6dy9.127948$wG.481599@rwcrnsc51.ops.asp.att.net>

Hi,

I'm creating an application which uses a class I've derived from CGI.pm.
For convenience, I'm using AUTOLOAD to access the class's data members,
rather than create methods for all.

My understanding is that perl will only call AUTOLOAD if the method is not
found in either the object's class, or its parent class(es). But AUTOLOAD
seems to be getting called for a "delete" method (I assume called by CGI's
constructor or destructor, because I haven't defined one.)

Here is the exception AUTOLOAD throws:
Uncaught exception: Can't access `delete' field in class Test at
F:/Gloc3/Development/Modules/Test.pm line 24.

Here is the code for Test.pm:
package Test;
use CGI;
use vars qw(@ISA);
use vars '$AUTOLOAD';
our @ISA = ("CGI");

sub new {
 my $that  = shift;
 my $class = ref($that) || $that;
 my $self = bless $that->SUPER::new(), $class;
 bless $self, $class;
 return $self;
}

sub AUTOLOAD {
 my $self = shift;
 my $type = ref($self) or die "$self is not an object";
 my $name = $AUTOLOAD;
 $name =~ s/.*://;   # strip fully-qualified portion
 unless (exists $self->{$name} ) {
   die "Can't access `$name' field in class $type";
 }
 if (@_) {
   return $self->{$name} = shift;
 } else {
   return $self->{$name};
 }
}

1;

Finally, here is cgi script that shows the bug in action:
use lib "F:/Gloc3/Development/Modules";
use strict;
use Test;

eval{
 my $session = Test->new();
 print $session->header();
};
if($@){
 print "Content-type: text/html\n\n";
 print "Uncaught exception: $@";
}

Any suggestions on what I am doing wrong?

Thanks in advance,
--
Kevin Lin
Wx3 Web Consulting
http://www.wx3.com/




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

Date: Wed, 6 Nov 2002 12:31:12 -0600
From: "Joe Moschak" <joe@amrita.net>
Subject: How to guarantee process ID stays with web connection
Message-Id: <aqbn60$88i$1@ins22.netins.net>

Every time I invoke a perl script from a web page, I get a different process
ID (PID) and consequently different values for any variables.  How can I
make it so that each time I invoke my script from a given web session I get
the same PID instead of a different one?  Below is code I use to verify that
I get different PIDs each time.

 # Write some pertinent info to a diagnostic file
  use strict;
  package DiagPrID;
  use POSIX;

  $root_path =
"/usr/local/psa/home/vhosts/amrita.net/httpdocs/cgi-local/wholesale";
  my $DiagnosticFile = (">>$root_path/diagnostic.txt");
  open( DIAGNOSTICFILE, $DiagnosticFile)
    or die "Couldn't open the $DiagnosticFile file for writing.\n";

  print  DIAGNOSTICFILE
"**************************************************************" .
      "******************************************\n";

  #What's left over from a previous invocation of this program?
  print  DIAGNOSTICFILE "Info before: \"$DiagPrID::HasThisBeenSetAlready\"
\n";
  #find the remote host
  my $remote_address = $ENV{'REMOTE_ADDR'};
  my @subnet_numbers = split (/\./,$remote_address);
  my $packed_address = pack ("C4",@subnet_numbers);
  my ($remote_host) = gethostbyaddr ($packed_address, 2);
  #get server time and format
  my $datestamp = strftime("%r %m/%d/%Y", localtime);
  #record when, from where, process id
  $DiagPrID::HasThisBeenSetAlready = ("Written \'$datestamp\' from
\'$remote_host\' process ID \'$$\'");
  print  DIAGNOSTICFILE "Info after:  \"$DiagPrID::HasThisBeenSetAlready\"
\n";

  close(DIAGNOSTICFILE);

Here's some sample output as recorded to diagnostic.txt:

****************************************************************************
****************************
Info before: "Written '12:02:27 PM 11/06/2002' from 'amrita1.natel.net'
process ID '564'"
Info after:  "Written '12:05:06 PM 11/06/2002' from 'amrita1.natel.net'
process ID '564'"
****************************************************************************
****************************
Info before: "Written '12:02:27 PM 11/06/2002' from 'amrita1.natel.net'
process ID '394'"
Info after:  "Written '12:06:28 PM 11/06/2002' from 'amrita1.natel.net'
process ID '394'"
****************************************************************************
****************************
Info before: "Written '04:24:37 PM 11/05/2002' from 'amrita1.natel.net'
process ID '393'"
Info after:  "Written '12:06:57 PM 11/06/2002' from 'amrita1.natel.net'
process ID '393'"

In the same web session I clicked a link that invoked my program 3 times
within a couple minutes.  But as you can see, each time I got a different
process id.  I want to be able to always get the same process ID when I'm in
a given web session.

Also, here is my httpd.conf file:
http://www.us-webmasters.com/httpd.conf.txt




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

Date: Wed, 6 Nov 2002 18:58:39 +0000 (UTC)
From: "F. Xavier Noria" <fxn@hashref.com>
Subject: Re: How to guarantee process ID stays with web connection
Message-Id: <aqboov$odl$1@news.ya.com>

In article <aqbn60$88i$1@ins22.netins.net>, Joe Moschak wrote:

> Every time I invoke a perl script from a web page, I get a different process
> ID (PID) and consequently different values for any variables.  How can I
> make it so that each time I invoke my script from a given web session I get
> the same PID instead of a different one?  Below is code I use to verify that
> I get different PIDs each time.

I could be wrong, but from your message it seems you want the same PID to
have the same data between different requests to the same program.

If that is right, your doubt is not about Perl, but you need to study how
CGIs work in general and which techniques exist to remember data between
different requests of a web session.

I would recommend reading this excellent book:

    CGI Programming with Perl, Second Edition
    http://safari.oreilly.com/?XmlId=1-56592-419-3
    
-- fxn


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

Date: 6 Nov 2002 08:53:06 -0800
From: pheelb@yahoo.com (Phil Brodd)
Subject: Re: Is it wrong to store method definitions in a database?
Message-Id: <69cfe521.0211060853.5a083bca@posting.google.com>

pheelb@yahoo.com (Phil Brodd) wrote in message news:<69cfe521.0211051457.110facaa@posting.google.com>...
> My project is a system that downloads and parses the contents of
> various web pages, each on its own collection schedule.  A Perl cron
> job checks a DB table to see if any pages are to be collected at that
> time, creating a Collector object for each one.  For each Collector
> object, methods are invoked to download the page, parse its contents,
> and insert the results in another DB table.

Thanks to Benjamin and Bryan for your helpful ideas.  I will
definitely use the smarter crontab technique and the Factory method of
creating Collector objects.  And I hadn't even considered storing
constructor args in the database (I'll try to be as anal as I know
how).


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

Date: Wed, 06 Nov 2002 14:34:20 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Net::FTP how can I change directory?
Message-Id: <h2aisuscvpp8ckgentbsasnn4e9m8lifns@4ax.com>

Jim McCallum wrote:

>Now that all seems fine, but the file "that.file" is
>retrieved to the location from where I execute
>my perl program, which is what I would expect.
>
>What I would like to do is always retrieve to a
>specific location.
>
>I've tried $ftp->quot("lcd /home/specific/location");
>before I do my get without any joy.
>
>How can I do the above from within my perl program?

Have you tried a simple chdir()?

-- 
	Bart.


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

Date: Wed, 06 Nov 2002 15:05:49 GMT
From: 122@jmccallum.NOSPAMfree-online.co.uk (Jim McCallum)
Subject: Re: Net::FTP how can I change directory?
Message-Id: <3dc92f65.22721386@newscore.theplanet.net>

>
>Have you tried a simple chdir()?
>
>-- 
>	Bart.

shockingly obvious and effective.
Many thanks.
Jim


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

Date: Wed, 06 Nov 2002 11:30:43 -0700
From: Todd Anderson <todd@mrnoitall.com>
Subject: param($var). 
Message-Id: <3DC95F80.C1411F68@mrnoitall.com>

Hello,
The code below replaces \n with <br> for param($var).
foreach $var (@display_items)
    {
        my $value = param($var);
        $value =~ s/\r\n/<br>/g;
        param($var, $value);
    }
I need to do the same thing with variables that have been converted ie:
$text = param('text');
Something like...
foreach $var (@display_items)
    {
        $var =~ s/\r\n/<br>/g;
    }
But this of course, only replaces \n in the handle name and not the
value.

Any help is appreciated
Thanks in advance for your help.



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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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


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


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