[17120] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4532 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 5 18:10:33 2000

Date: Thu, 5 Oct 2000 15:10:16 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <970783816-v9-i4532@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 5 Oct 2000     Volume: 9 Number: 4532

Today's topics:
    Re: Not Entirely On Topic:  Programming and math (Tim)
    Re: Not Entirely On Topic:  Programming and math <markmccarthy1@home.com>
    Re: Not Entirely On Topic:  Programming and math <gopalan@cs.sc.edu>
    Re: Not Entirely On Topic:  Programming and math (Craig Berry)
    Re: Perl and MySQL (Jon S.)
        Perl Reflection/Introspection d_brown3@my-deja.com
    Re: perl variables <lr@hpl.hp.com>
    Re: Problems with Perl2exe ... <carvdawg@patriot.net>
        Q: Creating a list of subs to execute <bill.lewis@corp.usa.net>
    Re: Q: Creating a list of subs to execute <bmb@ginger.libs.uga.edu>
    Re: Q: Creating a list of subs to execute <jeff@vpservices.com>
    Re: Q: Creating a list of subs to execute <uri@sysarch.com>
    Re: Q: Creating a list of subs to execute <jeff@vpservices.com>
    Re: Re-Interpolating Variables <geva@electra-supply.com>
    Re: Re-Interpolating Variables <geva@electra-supply.com>
    Re: Re-Interpolating Variables <lr@hpl.hp.com>
        Second Script <jaedma@yahoo.com>
        Seeking script for appending text file with web-form su m744@my-deja.com
        significance of "1;"at the end <pdmos23@geocities.com>
    Re: significance of "1;"at the end <bart.lateur@skynet.be>
    Re: significance of "1;"at the end <mtaylorlrim@my-deja.com>
    Re: Strange behavior with DESTROY and END sh_kell@my-deja.com
    Re: URL Redirect <flavell@mail.cern.ch>
        Using my with file handles <donv@webimpact.com>
    Re: Using my with file handles <bmb@ginger.libs.uga.edu>
        validating and decoding a code u0107@cheerful.com
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 05 Oct 2000 18:18:53 GMT
From: SPAM+indigo@dimensional.com (Tim)
Subject: Re: Not Entirely On Topic:  Programming and math
Message-Id: <8FC479F6Bindigodimcom@166.93.207.145>

lmoran@wtsg.com (Lou Moran) wrote in 
<35eptscl81drjr8gn9teh5ol2a2p00gcql@4ax.com>:

>--Is a strong background in mathematics (not arithmetics) mandatory
>for a successful career as a programmer?
>
>--Could a creative (musician/writer/painter/whatever) person become a
>"real" (read useful/good/paid) programmer without having mathematical
>prowess?

Some kinds of programming are more math heavy than others, but in 
general, programming is going to require good math skills no matter
what you do.

What is good enough?  Hard to say.  Most of the specifics I learned
in my math courses have never come up.  But the quantative analysis
skills I had to develop in order to excel in math, I use those all the
time.

I have always had a love/hate relationship with math.  10% of it is
fascinating, 90% is drudgery.  That's what so great about the computer
field...you only have to remember the cool math, and leave the drudgery
to the machines.

Here is the math like skills I would look for:

o Strong Logic 
o In your head Arithmetic
o Numeric Memory
o Basic Statistics and Probability
o Basic Cartesian Geometry
o Visualiztion

I am sure others can add to this list.

-T


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

Date: Thu, 05 Oct 2000 19:09:59 GMT
From: "Mark McCarthy" <markmccarthy1@home.com>
Subject: Re: Not Entirely On Topic:  Programming and math
Message-Id: <bm4D5.11385$3_4.160335@news1.rdc1.sdca.home.com>


"Lou Moran" <lmoran@wtsg.com> wrote in message
news:35eptscl81drjr8gn9teh5ol2a2p00gcql@4ax.com...
> --Is a strong background in mathematics (not arithmetics) mandatory
> for a successful career as a programmer?

Inasmuch as math teaches you how to think about problem solving, programming
and mathematics are one and the same discipline. As far as specific math, it
helps not a jot. Just like in programming, you have to RTFM. I have a math
MA and no formal programming training; I recall nothing - nay I discarded
everything - from my math years and on rare ocassion when I do need it, TFM
suffices. Perl et al. came relatively easily to me since I have certain
thinking skills in place.

Mark McCarthy




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

Date: Thu, 5 Oct 2000 14:41:40 -0400
From: Gopi Sundaram <gopalan@cs.sc.edu>
Subject: Re: Not Entirely On Topic:  Programming and math
Message-Id: <Pine.OSF.4.21.0010051439110.9954-100000@pearl.cs.sc.edu>

On Thu, 5 Oct 2000, Lou Moran wrote:

> --Could a creative (musician/writer/painter/whatever) person
> become a "real" (read useful/good/paid) programmer without having
> mathematical prowess?

I didn't think that one could be a competent musician without
significant mathematical skill.

In any case, methematical knowledge isn't always what helps a
programmer, it is the thought process in problem-solving that
mathematics teaches that helps so much.

There are of course a great many things in programming that require
various aspects of mathematics, but those usually depend on the kind
of projects you are working on.

-- 
Gopi Sundaram
gopi@cs.sc.edu



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

Date: Thu, 05 Oct 2000 21:04:30 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Not Entirely On Topic:  Programming and math
Message-Id: <stpr6u4ou9glba@corp.supernews.com>

Lou Moran (lmoran@wtsg.com) wrote:
: --Is a strong background in mathematics (not arithmetics) mandatory
: for a successful career as a programmer?

No; in fact, it's nearly irrelevant unless you want to get into
scientific, engineering, or mathematical programming. 

: --Could a creative (musician/writer/painter/whatever) person become a
: "real" (read useful/good/paid) programmer without having mathematical
: prowess?

Yes, if you have a talent for methodical, well-organized thought combined
with that creativity.

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "Quidquid latine dictum sit, altum viditur."
   |


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

Date: Thu, 05 Oct 2000 21:37:38 GMT
From: jonceramic@nospammiesno.earthlink.net (Jon S.)
Subject: Re: Perl and MySQL
Message-Id: <39dcf442.29433062@news.earthlink.net>

On Thu, 05 Oct 2000 13:31:00 +0100, Atul <atul.patel@uk.sun.com>
wrote:

>Folks,
>
>are there any example perl scripts which makes
>use of MySQL ?? ... just to help me get started.
>
>A.

In addition to the other poster's great info, you can check out the
sample chapter of OReilly's mSQl/MySQL book online.  Plus,
www.slashcode.com is all MySQL and Perl and downloadable to try and
comprehend.  (I couldn't, so I bought "Programming the Perl DBI" and
downloaded the MySQL and DBI docs from online.)

Best of luck,

Jon


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

Date: Thu, 05 Oct 2000 21:29:09 GMT
From: d_brown3@my-deja.com
Subject: Perl Reflection/Introspection
Message-Id: <8rirqq$r9m$1@nnrp1.deja.com>

Can someone point me to a good online reference on using reflection in
Perl?  The only thing I've been able to find was the short section in
the Advanced Perl Programming book.


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 5 Oct 2000 13:08:38 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: perl variables
Message-Id: <MPG.14467fa2169fd9a98ae0f@nntp.hpl.hp.com>

In article <hs_C5.35953$Z2.521632@nnrp1.uunet.ca> on Thu, 5 Oct 2000 
08:36:46 -0400, web <swebster@telnet.ca> says...
> Can i create a variable with a value that has a space between characters?
> eg. $fromaddr = $in{'E-mail Address'};
> 
> Or does it all have to be one word?

You seem to be referring to a hash key, not to the name of a variable 
(which must be an identifier -- look that up in the Perl documentation).

Any string may be used as a hash key.  Yes, *any* string!

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


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

Date: Thu, 05 Oct 2000 18:12:53 -0400
From: H C <carvdawg@patriot.net>
Subject: Re: Problems with Perl2exe ...
Message-Id: <39DCFCE5.CA46F171@patriot.net>

> I've got CGI programs in PERL, and I don't want someone to be able to read
> my codes. So, I've tried Perl2exe ... It seems working well, but sometimes,
> I have problems ...

Well, perhaps if you posted some more info, like the code, what (EXACTLY)
the problem is and what precipitates it, what web server you're using, etc,
etc...

> Does someone have experience with Perl2exe ??

Yeah.  And so does the author of the tool....




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

Date: Thu, 05 Oct 2000 19:32:19 GMT
From: "William L. Lewis" <bill.lewis@corp.usa.net>
Subject: Q: Creating a list of subs to execute
Message-Id: <39DCD6A9.C33165FA@corp.usa.net>

Hi all,
  I was thinking of creating a configuration file that a program would
read, and build a list of the subroutines within the program to run. 
the configuration file would be something simple like <subname>=y/n to
determine which routines to execute.  I have them in an array but how to
I go about formatting a &<subname> command to execute?
 Could you email me with any responses? 

thanks,
Bill lewis
email: bill.lewis@corp.usa.net


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

Date: Thu, 5 Oct 2000 15:50:26 -0400
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: Q: Creating a list of subs to execute
Message-Id: <Pine.A41.4.21.0010051548310.12502-100000@ginger.libs.uga.edu>

On Thu, 5 Oct 2000, William L. Lewis wrote:

> Hi all,
>   I was thinking of creating a configuration file that a program would
> read, and build a list of the subroutines within the program to run. 
> the configuration file would be something simple like <subname>=y/n to
> determine which routines to execute.  I have them in an array but how to
> I go about formatting a &<subname> command to execute?
>  Could you email me with any responses? 
> 
> thanks,
> Bill lewis
> email: bill.lewis@corp.usa.net
> 

There was a note earlier today that answers this.  I believe the phrase
"dispatch table" was in it somewhere.

Brad



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

Date: Thu, 05 Oct 2000 12:52:08 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Q: Creating a list of subs to execute
Message-Id: <39DCDBE8.55650990@vpservices.com>

"William L. Lewis" wrote:
> 
>   I was thinking of creating a configuration file that a program would
> read, and build a list of the subroutines within the program to run.
> the configuration file would be something simple like <subname>=y/n to
> determine which routines to execute.  I have them in an array but how to
> I go about formatting a &<subname> command to execute?

This prints "hello world":

use strict;
{
    no strict 'refs';
    for my $sub('first','third') { &$sub }
}
sub first  { print "hello " }
sub second { print "foobar" }
sub third  { print "world"  }
__END__

>  Could you email me with any responses?

No, sorry: post here, read here.  Usenet is a group enterprise, not a
private help desk.

-- 
Jeff


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

Date: Thu, 05 Oct 2000 19:59:14 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Q: Creating a list of subs to execute
Message-Id: <x7k8bn3vqk.fsf@home.sysarch.com>

>>>>> "JZ" == Jeff Zucker <jeff@vpservices.com> writes:

  JZ> use strict;
  JZ> {
  JZ>     no strict 'refs';
  JZ>     for my $sub('first','third') { &$sub }
  JZ> }
  JZ> sub first  { print "hello " }
  JZ> sub second { print "foobar" }
  JZ> sub third  { print "world"  }

much better to use hard refs and a dispatch table. if the key being
passed in is not legal you can get a fatal error or in a class call
AUTOLOAD or do other nasty damage. keep symrefs where they belong,
behind the curtain with the wizard.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Thu, 05 Oct 2000 13:04:18 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Q: Creating a list of subs to execute
Message-Id: <39DCDEC2.DD0EB2B8@vpservices.com>

Uri Guttman wrote:
> 
> >>>>> "JZ" == Jeff Zucker <jeff@vpservices.com> writes:
> 
>   JZ> use strict;
>   JZ> {
>   JZ>     no strict 'refs';
>   JZ>     for my $sub('first','third') { &$sub }
>   JZ> }
>   JZ> sub first  { print "hello " }
>   JZ> sub second { print "foobar" }
>   JZ> sub third  { print "world"  }
> 
> much better to use hard refs and a dispatch table. if the key being
> passed in is not legal you can get a fatal error or in a class call
> AUTOLOAD or do other nasty damage. keep symrefs where they belong,
> behind the curtain with the wizard.

So, that's why my "fly" sense was tingling as I sent that. :-)

-- 
Jeff


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

Date: Thu, 5 Oct 2000 14:25:52 -0400
From: "Greg Eva" <geva@electra-supply.com>
Subject: Re: Re-Interpolating Variables
Message-Id: <8rih53$bfk$1@cougar.golden.net>


"NP" <nvp@spamnothanks.speakeasy.org> wrote in message
news:651D5.5386$UP5.73225@news6.giganews.com...
> geva@electra-supply.com wrote:
> :
> : This works fine, because it interpolates when it is setting $mesg.  But
wht
> : I want to do is interpolate something that I am inputting.  For instance
> : from a file.  Pull in a string from a file, and have Perl interpolate a
> : variable name that I have stragically place in the file.
>
> There are several ways that you can do this.
>
> First, I believe that Text::Template can handle what you propose.
>

I am not familiar with this module, but will look into it.


> Or, if I understand your question correctly, you have a text file that
> looks like this:
>
> $ cat /tmp/interp.txt
> The value of \$foo is a $foo.
>
> And this line doesn't contain any variables.
>
> Well, $name, thanks for playing!
>
> <EOF>
>
> And you want the strings $foo and $name to be replaced with the values
> of $foo and $name.
>

Yup, exactly what I am trying to do.

> I believe that this code should help you out.
>
> #!/usr/bin/perl -w
>
> my $name = "Nate";
> my $foo = "blah blah";
>
> open(IN, "/tmp/interp.txt")
>     or die("can't open $file: $!");
> my @lines = <IN>;
> close(IN);
>
> foreach my $line (@lines) {
>     chomp($line);
>     print eval "qq[$line]","\n";
> }
>

I tried using an eval as I thought that should do the trick, I used a block,
and didn't use the qq// method of quoting.  I will try it and let you know.

> This outputs:
>
> The value of $foo is a blah blah.
>
> And this line doesn't contain any variables.
>
> Well, Nate, thanks for playing!
>
> --
> Nate II

Thanks for the help.. it's appreciated.  Now I can get back to work!
Yeah!!!

Greg




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

Date: Thu, 5 Oct 2000 14:31:19 -0400
From: "Greg Eva" <geva@electra-supply.com>
Subject: Re: Re-Interpolating Variables
Message-Id: <8rihfe$bm5$1@cougar.golden.net>


"Brendon Caligari" <bcaligari@my-deja.com> wrote in message
news:8ri7ii$8gq$1@nnrp1.deja.com...
> In article <8ri4u9$6h1$1@cougar.golden.net>,
>   "Greg Eva" <geva@electra-supply.com> wrote:
> > This works fine, because it interpolates when it is setting $mesg.
> But wht
> > I want to do is interpolate something that I am inputting.  For
> instance
> > from a file.  Pull in a string from a file, and have Perl interpolate
> a
> > variable name that I have stragically place in the file.
> >
> > Hope someone can help, as this would simplify our work much.
> >
> > Greg
> >
> >
>
> how about using regex substitutions?
>

This is what I am doing now.  I don't feel like this is an efficient method
of doing it though.

> suppose you have read a line into scalar, say $sharmuta
>
> $sharmuta may contain a stirng, say <myname>
>
> you would want to replace all instances of <myname> in
> $sharmuta with scalar $realname
>
> you could use something like
>
> $sharmuta =~ s/<myname>/$realname/g;
>

I am using something like this..

s/(?=[^\\])$(\w+)/${$1}/g;

 .. this wouldn't take care of this problem, the fact that you could have a
variable called $cat, and trying to interpolate $cateract.. it wouldn't
interpolate.  I guess I could use minimal matching however.

s/(?=[^\\])$(\w+?)/${$1}/g;

Thanks for the help!

Greg
> brendon
> ++++
>
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.




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

Date: Thu, 5 Oct 2000 13:30:19 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Re-Interpolating Variables
Message-Id: <MPG.144684b3a19b163d98ae10@nntp.hpl.hp.com>

In article <8rihfe$bm5$1@cougar.golden.net> on Thu, 5 Oct 2000 14:31:19 
-0400, Greg Eva <geva@electra-supply.com> says...

 ...

> I am using something like this..
> 
> s/(?=[^\\])$(\w+)/${$1}/g;

Apparently your intent is to recognize a dollar-sign that is not 
preceded by a backslash, to signal interpolation.  But that regex 
doesn't do it, for a couple of reasons:

1.  If you indeed had '\$foo', the match would succeed starting from the 
second character.  You would do better with a negative look-behind.

2.  You must escape the $ in the regex, or the regex will try to match 
the end of the string.  (I don't know why Perl doesn't just interpolate 
the value of the special variable $( (see perlvar).  Perhaps because it 
wouldn't interpolate $) because of common DWIM.)

So:

  s/(?<!\\)\$(\w+)/${$1}/g;

But that uses a greasy, ugly, horrible symbolic reference.  You would do 
much better to use a hash, as suggested in the FAQ you were referred to 
by Jeff Zucker.
 
> .. this wouldn't take care of this problem, the fact that you could have a
> variable called $cat, and trying to interpolate $cateract.. it wouldn't
> interpolate.  I guess I could use minimal matching however.
> 
> s/(?=[^\\])$(\w+?)/${$1}/g;

Even corrected as shown above, that would match only one character after 
the $.  You need some formal termination to the string.

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


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

Date: Thu, 5 Oct 2000 14:25:34 -0500
From: "Jim" <jaedma@yahoo.com>
Subject: Second Script
Message-Id: <39dcd5ec$0$28240$7f8943f3@newsreader.visi.com>

pass me


I have a form that when filled out, and submit is pressed, info goes to a
CGI script(has it should).
My question is -  I have 1 text box, that I want to go to a separate script,
can this be done.
In other words I want  6 text box's info to go to Script1, text box 7 should
go to script2.
  Thanks  Jim



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

Date: Thu, 05 Oct 2000 21:21:51 GMT
From: m744@my-deja.com
Subject: Seeking script for appending text file with web-form submissions
Message-Id: <8rird4$qse$1@nnrp1.deja.com>

Hi,

I have a page on my site where users enter their name and
email address in a form. I'd like to append this information
to a comma-delimited text file, suitable for import to a
database or spreadsheet. Could anyone refer me to any
existing scripts?

Thanks!


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 05 Oct 2000 19:43:44 GMT
From: Pasquale <pdmos23@geocities.com>
Subject: significance of "1;"at the end
Message-Id: <39DCDA9E.3C4060B@geocities.com>

I was just curious if there is any significance to having "1;" at the
end of a script?  Is it better practice with or without?
Thanks
Pasquale



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

Date: Thu, 05 Oct 2000 20:08:12 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: significance of "1;"at the end
Message-Id: <8snpts4kb013ufrj8tqvd1377734tiqht0@4ax.com>

Pasquale wrote:

>I was just curious if there is any significance to having "1;" at the
>end of a script?  Is it better practice with or without?

End of script? No. End of library file, yes. This is a marker to Perl
that "This is a valid perl library file, and loading went well."

It can be that this will be dropped in Perl6 (in a few years time).

-- 
	Bart.


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

Date: Thu, 05 Oct 2000 21:27:09 GMT
From: Mark <mtaylorlrim@my-deja.com>
Subject: Re: significance of "1;"at the end
Message-Id: <8rirn1$r1d$1@nnrp1.deja.com>

And to supplement Bart's answer...

The 1; is also added to the end of a subroutine which exists in another
file. The 1; has the same significance, to signify sucessful loading.

Mark


In article <39DCDA9E.3C4060B@geocities.com>,
  Pasquale <pdmos23@geocities.com> wrote:
> I was just curious if there is any significance to having "1;" at the
> end of a script?  Is it better practice with or without?
> Thanks
> Pasquale
>
>

--
Please reply to this newsgroup as my Deja mail
is used as a spam catcher only!


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 05 Oct 2000 21:52:47 GMT
From: sh_kell@my-deja.com
Subject: Re: Strange behavior with DESTROY and END
Message-Id: <8rit7c$se6$1@nnrp1.deja.com>

In article <39DBE2AA.2ED78660@rochester.rr.com>,
  Bob Walton <bwalton@rochester.rr.com> wrote:
>
>
> sh_kell@my-deja.com wrote:
> ...
> > > Well, the DESTROY method gets called when an object gets
destroyed.
> > > Destruction of the lexical variable my $test occurs when $test
goes
> > out
> > > of scope.  That is right after it is created, and before the
program
> > > ends.  The global variable $test, on the other hand, persists
until it
> > > is destroyed in the END processing.  To see this even more
clearly,
> > add
> > > a block around the my $test=... and a print statement afterwards,
like
> > > so:
> > >
> > >    use Test;
> > >    {
> > >       my $testlexical=new Test;
> > >       $testglobal=new Test;
> > >    }
> > >    print "Hi from after the block\n";
> > >
> > > --
> > > Bob Walton
> >
> > I understand that an object's destructor is called when the object
goes
> > out of scope. My whole question is why does the class END block get
> > called before the DESTROY is issued for all instantiated objects of
> > that class?
> >
> > It seems to me that the END block (being a class wide destructor)
> > should ALWAYS be executed after the DESTROY for the last object of
that
> > class else all class variables cease to exist and are not available
to
> > be used by the other remaining objects of that class.
> >
> > The example above was a simplified version of my entire, more
complex
> > problem. In the module I have, in the DESTROY method it has
something
> > similar to:
> >
> > DESTROY{
> >     my $self = shift;
> >     $self->_flush() if $objectCount == 0;
> > }
> >
> > Where _flush() writes the latest info to the database (in this case
a
> > number that all objects in the class update to get a unique ID). Now
> > since the database handle is class-wide once I reach the end of my
> > program it calls main::END, Class::END then DESTROY for objects (if
> > objects were not instantiated via 'my')
> >
> > This means that once _flush() is called it cannot update the
database
> > since the handle has been destroyed and made inaccessible.
> >
> > Now in the perltoot manpage it states:
> >
> > "The object destructor handles the death of each distinct object.
But
> > sometimes you want a bit of cleanup when the entire class is shut
down,
> > which currently only happens when the program exits. To make such a
> > class destructor, create a function in that class's package named
END.
> > This works just like the end function in traditional modules,
meaning
> > that it gets called whenever your program exits unless it execs or
dies
> > of an uncaught signal."
> >
> > I guess the exact time a program is deemed 'exited' is at the time
> > main::END is called which does not care that there may be other
objects
> > of a given class left and immediately calls all ENDs on down the
line
> > thereby destroying any class variables that those objects may have
> > needed.
> ...
> Hmmmmm...well, at the risk of delving in where I don't really know
very
> much, it seems to me like you have created objects that don't really
> follow the object-oriented paradigm.  If each and every one of your
> objects contained a reference to the filehandle variable that you say
> goes out of scope before DESTROY gets called for that object, then the
> filehandle wouldn't be trashed, since it would still be referenced.
The
> paradigm, as I understand it, is that an object should contain
> *everything* about itself, and that nothing it needs should exist
> without dependence upon the object -- that is, it shouldn't be
permitted
> to go out of scope until the object itself is out of scope.  A global
> filehandle that does not have a reference to it in the object would
be a
> prime example.  The reference might be just for the purpose of keeping
> the filehandle around for DESTROY -- but then if a reference to the
> filehandle is maintained, then it wouldn't be necessary to use a
global
> variable to reference the filehandle in the DESTROY method, thereby
> making it more general.  By maintaining a reference, the destruction
> order shouldn't matter.  I doubt that Perl or anything else could grok
> the "correct" destruction order in complicated situations anyway.
HTH.
> --
> Bob Walton

Actually this is exactly what I had... a reference to the database
handle last used. I found the problem to be that upon destruction, the
object needed a previously cached handle and if no other object had a
reference to this handle then it was removed since its reference count
was then zero.

This was dependant on how the object was used and what order things
were carried out and thus difficult to duplicate.

The module itself is designed to take from 1 to N connections arranged
either individually (by unique name) or as a group (numerous
connections with same name). Then when you call a 'query' method and
pass in a connection name, the query is done on that connection. If you
pass a group name, it will choose a connection to query on (since all
database across this cluster are synched).

On a 'do' method it does same thing except when a group is passed, the
query is performed on all servers in the group.

All connections are made to be persistant via FreezeThaw so if you
request a connection to same server more than once it just thaws its
cached connection and uses that rather than reconnecting per object
instantiation (thus reason for making it class-wide).

The problem I think is in the internal class reference counting that
tells what object is using which connection (it uses this for a sort of
load balancing so all objects aren't hitting the same database server
at the same time). It would attempt to keep all of these connections
alive and a reference to them to prevent exactly what you describe. It
is bugged somehow where the references are being either overwritten or
undef'ed somewhere.

Being a rather large module, I think I may just break it down and redo
it to make it more managable. Problem is I just added a subclass to
handle replication and master/slave relationships so that again added a
bit more complexity. (all this is for MySQL database)

Maybe we should just switch to Oracle since it does all this already :)










Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 5 Oct 2000 20:11:47 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: URL Redirect
Message-Id: <Pine.GHP.4.21.0010051945130.3117-100000@hpplus03.cern.ch>


On Thu, 5 Oct 2000, Jerry Leventer proved yet again the old adage
about upside-down fullquoters, by stealthily changing the Subject
line, and then blurting out:

> Create an html file at the URL that you want to redirect FROM with
> something like the following:
[...]
>   <META HTTP-EQUIV="Refresh"  CONTENT="0;
> URL=http://redirect_to_your_site.com/your_file.htm">

and afterwards quoting the question we've seen several times before
but which he had clearly failed to comprehend, in spite of the
previous refutations on this thread:

> > I'm looking for a perl script that will automatically open up another
> > url
> > when exiting the original, 
    ^^^^^^^^^^^^^^^^^^^^^^^^^

Deja, for example, would be happy to show you the existing thread
which has already discussed this some days ago, and might help you to
understand why your follow up was the wrong answer to the wrong
question.

If a normal redirection was required in this context, then the one
described in the Perl FAQ would be the one to use, i.e the HTTP
redirection by means of Location: header.

If a delayed refresh to a different URL was required, then your answer
might have been appropriate (but a refresh with a delay of 0 is just
plain _RUDE_).

But neither of these are answers to the question that was asked.

Obviously, the only possible answer to that would be based on
client-side scripting.  The only way _that_ could be achieved with a
_perl_ script is if the reader had enabled their browser to execute
perl scripts, which, unless this is an intranet under the hon.
Usenaut's control, is highly unrealistic.  Javascript is probably what
the hon. Usenaut has seen in action when using other sites, and the
likely place to find more about that would be comp.lang.javascript (or
rather, its comprehensive FAQ).  Of course, readers can and do disable
javascript for various reasons (this would likely be another one of
them).

OK, pick your own f'up group, flame away.



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

Date: Thu, 05 Oct 2000 14:24:02 -0400
From: Don Vaillancourt <donv@webimpact.com>
Subject: Using my with file handles
Message-Id: <39DCC742.79385B01@webimpact.com>

Is there a way to perform  the following:

sub foo
{
    my FILEHANDLE;
}

The above 'my' does not work with file handle variables.  Is there a way
to localize the definition of a file handle to a single subroutine.
I've tried  the following without success.

sub foo
{
    my *FILEHANDLE;
}

That doesn't work either.  The reason I'm asking is because I wrote a
database class in PERL which manipulates it's own database files.  This
class contains a FILEHANDLE variable.  This file handle is stored and
retrieved from the class structure using type globs.  But I have a
feeling that the variable FILEHANDLE that I use in every single
function, such as the example below gets corrupted or altered by each
function.

# go to the first record
sub goFirstRecord
{
 my $self=shift @_;

 *HANDLE = $self->{handle};

 if (seek HANDLE, 0, 0)
 {
  $self->{current_record}++;
  return 1;
 }
 else
 {
     return 0;
 }
}

Thank You





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

Date: Thu, 5 Oct 2000 14:37:33 -0400
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: Using my with file handles
Message-Id: <Pine.A41.4.21.0010051436490.12502-100000@ginger.libs.uga.edu>

On Thu, 5 Oct 2000, Don Vaillancourt wrote:

> Is there a way to perform  the following:
> 
> sub foo
> {
>     my FILEHANDLE;
> }
> 

perldoc -q "How can I make a filehandle local to a subroutine?"

Brad



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

Date: Thu, 05 Oct 2000 19:34:00 GMT
From: u0107@cheerful.com
Subject: validating and decoding a code
Message-Id: <8ril39$kmj$1@nnrp1.deja.com>

Hello,

I am trying to do the following:

I have a form on my webpage consisting of more than one field.  One of
the fields, a text box,  is an item code in a flat file of some 35,000
records.

As soon as an item code is entered, I would like to call a perl script,
(I would like to avoid using javascript as that would make my source
accessible and reveal details I would not like to reveal about my
website) and get the decode (item description) of that item code and
display it in a readonly type of input.

I am fairly comfortable with javascript and I can code well enough to
detect a change in the content of the text box field to pass it to a
javascript function.

What I would like to do is:

Use this passed (item code) value in the javascript function to pass it
to a perl program which would accept this passed value and return to me
the decode of the item (item description) which I could display on the
page dynamically WITHOUT ANY KEY DEPRESSION necessitated.

My question is:

Am I going about it the right way or is there a better way? (e.g. using
onKeyDown and onKeyUp events in forms to directly call the perl script
instead of passing it to a javascript function...?)

If there IS a better way, then can someone point me to it?

Thanks in advance.

I would prefer personal / direct emails to my email address.  I will
share in this forum, all solutions which I receive and find working
with any changes I need to effect.

Cheers!

Uttam


Sent via Deja.com http://www.deja.com/
Before you buy.


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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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

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

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


------------------------------
End of Perl-Users Digest V9 Issue 4532
**************************************


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