[17439] in Perl-Users-Digest
Perl-Users Digest, Issue: 4859 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 9 18:10:40 2000
Date: Thu, 9 Nov 2000 15:10:18 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <973811418-v9-i4859@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 9 Nov 2000 Volume: 9 Number: 4859
Today's topics:
Re: OOP and information hiding (Damian Conway)
Re: OOP and information hiding (Damian Conway)
Perl 5.6.0 hangs when out of bounds octal # assigned eggrock@my-deja.com
Re: Perl 5.6.0 hangs when out of bounds octal # assigne (Tad McClellan)
Re: Pushing a hash on to a stack... (Christopher Burke)
Re: qx(...&); hangs program <mjcarman@home.com>
Re: reconstituting hash from reference? (Chris)
Re: Running a remote CGI script through perl <pwthoma@arkansas.net>
Re: Running a remote CGI script through perl <flavell@mail.cern.ch>
Taint mode and file globbing <godoy@conectiva.com>
Re: udp server - high volume - log switch (Chris Fedde)
Re: Use Eval to open file? <ren.maddox@tivoli.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 9 Nov 2000 20:09:02 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: Re: OOP and information hiding
Message-Id: <8uf08t$8ak$1@towncrier.cc.monash.edu.au>
abigail@foad.org (Abigail) writes:
>There is another trade-off, and that's the sheer explosion of punctuation
>characters - a minor peeve I have against Perl OO style programming.
>I'd write this in Perl:
> my @array;
> push @array => 1, 2, 3, 4;
>And this in OO-Perl with SecureHashes:
> my $self = shift;
> push @{$self -> {__array}} => 1, 2, 3, 4;
No, you write:
$self->push_array(1,2,3,4);
The whole point of OO is to "encapsulate the horridness". :-)
Damian
------------------------------
Date: 9 Nov 2000 23:03:11 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: Re: OOP and information hiding
Message-Id: <8ufaff$887$1@towncrier.cc.monash.edu.au>
Bart Lateur <bart.lateur@skynet.be> writes:
> As always, Damina likes complex solutions. ;-)
As always, Damian likes complete solutions. ;-)
^^
Your interesting alternative doesn't address scope restriction, nor typo
detection.
Besides which, I would argue that securehashes are a *less* complex
solution that your clever subroutine. Sure, you have to call
Tie::Securehash::new in the constructor (how incredibly complex!), but
then you can just use the objects like ordinary hashes without thinking
about accessibility or collisions, until you do something stupid *and
the module tells you!*
Under your proposal, if I forget to __(...) the attribute name in some
method, or if I misspell it, the hash silently autovivifies another
unrelated attribute :-(
> In principle, the language *could* provide an easy way to give
> Perlish (= so simple you can hardly believe it), private keys.
> My idea is to extend the package qualification idea from global
> variables, to hash keys, with a special, er, "marker". So a private
> hash key "Bar" in a package "My::Class" would actually form the hash
> key string "My::Class::Bar".
This is still "privacy by convention", which is no privacy at all.
Have you looked at RFC 188 (http://dev.perl.org/rfc/188.html), which
proposes something analogous to your scheme, but *also* proposes
securehash-like semantics that make it safe?
> One more problem is with the necessary (usually) quoting of the
> argument to __(). Sigh. It would be nice, through prototypes, to be
> able to autoquote the argument. (Can't Lisp do that?)
RFC 128 (http://dev.perl.org/rfc/128.html) would allow that under Perl 6:
sub __ ("");
Damian
------------------------------
Date: Thu, 09 Nov 2000 19:50:01 GMT
From: eggrock@my-deja.com
Subject: Perl 5.6.0 hangs when out of bounds octal # assigned
Message-Id: <8uev56$bjm$1@nnrp1.deja.com>
Hasty, ill-thought out code parses a string and pulls a date in YYMMDD
format, then assigns to $year, $month, $mday with YY, MM and DD,
respectively.
If any of the three contain zero as the first digit the number is
treated as octal. On the occurrence of "08" or "09", the script just
hangs, no errors, no warnings (-w switch is used).
The problem no doubt arose because of bad programming but I would expect
some sort of crash and burn when trying to assign an illegal value. Is
it a bug?
My fix (read "workaround") was to check the first digit and if it's a
zero then just assign the second digit to the variable. I'm sure there
are better ways... ;) (I'll figure it out but if someone wants to post a
good solution for the benefit of others feel free.)
Again, it's Perl 5.6.0 running on a Digital system (4.0).
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 9 Nov 2000 15:28:25 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Perl 5.6.0 hangs when out of bounds octal # assigned
Message-Id: <slrn90m279.c70.tadmc@magna.metronet.com>
On Thu, 09 Nov 2000 19:50:01 GMT, eggrock@my-deja.com
<eggrock@my-deja.com> wrote:
>Hasty, ill-thought out code parses a string and pulls a date in YYMMDD
>format, then assigns to $year, $month, $mday with YY, MM and DD,
>respectively.
>
>If any of the three contain zero as the first digit the number is
>treated as octal. On the occurrence of "08" or "09", the script just
>hangs, no errors, no warnings (-w switch is used).
You appear to have forgotten to include the code that you
want debugged.
Got code? (_short_ and complete that illustrates your problem)
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 09 Nov 2000 21:10:30 GMT
From: craznar@hotmail.com (Christopher Burke)
Subject: Re: Pushing a hash on to a stack...
Message-Id: <8FE84AF91Craznar@24.192.1.17>
ren.maddox@tivoli.com (Ren Maddox) wrote in
<m366lxlvyp.fsf@dhcp11-177.support.tivoli.com>:
>craznar@hotmail.com (Christopher Burke) writes:
>
>> To clarify - the 'push line can use references until the cows come
>> home' however the code that puts the elements into the hash CANNOT,
>> and neither can the code that extracts the elements at the end.
>>
>> i.e.
>>
>> %hash{x} = 3; # this line is fixed
>> %hash{y} = 4; # as is this
>
>Actually, these two lines are syntax errors. I'll assume you mean for
>those "%"s to be "$"s.
Yes the % are meant to be $
>> push @fulldata, ???(%hash)??? # whatever references you want
>> print $fulldata[0]{x}; # this line is fixed - prints 3
>> print $fulldata[0]{y}; # this line is fixed - prints 4
>
>And these two lines use references. $fulldata[0] holds a reference to
>a hash. $fulldata[0]{x} is just a shorthand for $fulldata[0]->{x},
>which is, itself, a shorthand for ${$fulldata[0]}{x}.
>There be references here....
Well I cannot see any references there, must mean I just have different
words to express things. That language difference seems to have cursed me
in this newsgroup.
>Assuming you're OK with the fact that these are references, then the
>push line can simply be:
>
> push @fulldata, { %hash }; # which creates a new hash explicitly
I'll give that one a go...
>or, if %hash is a lexical that will go out of scope every time:
>
> push @fulldata, \%hash; # but do not reuse the same %hash
That one doesn't work ... because, even with creating new %hash each loop.
>Does that work for you?
>
Thanks for the response.
--
---
/* Christopher Burke - Spam Mail to craznar@hotmail.com
|* www.craznar.com - International Internet Writing Experiment
\* Real mail to cburke(at)craznar(dot)com
------------------------------
Date: Thu, 09 Nov 2000 12:43:36 -0600
From: Michael Carman <mjcarman@home.com>
Subject: Re: qx(...&); hangs program
Message-Id: <3A0AF058.F801831B@home.com>
pelle1970@my-deja.com wrote:
>
> qx(/MyDir/MyExec $MyArray[$MyIdx] MyParams
> 2>/MyLogDir/err$MyArray[$MyIdx] &);
>
> now when that line gets executed, the perl-script waits for the result
> of MyExec. I don't need that, since these Execs are supposed to be
> running forever (which IS the reason that I check if they are truly
> running).
> Is there any way to just start the program without checking on
> it? I'd like to avoid forks!!!
> [...]
> P.S. I read about exec and system, but both seem to wait for the output
> of the executed program, right? - That doesn't help me.
Not exactly, you should go back and read the docs more carefully. exec()
never returns -- it launches a new process in place of the current one.
system() returns status, not output. Use backticks if you want the
output of a command.
How are you executing your command? If you launch your command in the
background (which is what the trailing '&' should do) system() should
return immediately.
-mjc
------------------------------
Date: Thu, 09 Nov 2000 19:30:17 GMT
From: cpr@intergate.ca (Chris)
Subject: Re: reconstituting hash from reference?
Message-Id: <3a0afacb.94410595@news.intergate.ca>
On Thu, 9 Nov 2000 21:47:15 +1100, mgjv@tradingpost.com.au (Martien
Verbruggen) wrote in comp.lang.perl.misc:
>So, after this digression (and who the hell knows why I decided to blab
>on about all this):
>
>%hash = %{$data{stuff}};
>
>@keys = keys %{$data{stuff}};
Thanks. That's exactly what I needed to know.
In actual truth I'm extracting a hash from a hash in an array, but I
extended the cast and managed to get it to work.
------------------------------
Date: Thu, 09 Nov 2000 15:17:24 -0600
From: MrPaul <pwthoma@arkansas.net>
Subject: Re: Running a remote CGI script through perl
Message-Id: <8u4m0toahq6279ot1k03thprospaigk8ki@4ax.com>
I'm glad that there are people in the world like you that make life so
pleasurable for others.
Paul
On 09 Nov 2000 18:29:18 +0000, nobull@mail.com wrote:
>MrPaul <pwthoma@arkansas.net> writes:
>
>> I'm trying to write a perl script that will run a CGI script on a
>> remote web server. I've looked through CPAN and 3 months of this
>> group
>
>Since this question is typically asked and answered at least twice a
>week and often more than once a day that would be around 25-100
>instances of this question. You can't have looked very carefully.
>
>> but unfortunately I just started programming perl yesterday
>> and I'm not really sure what to look for.
>
>That's not really relevant since it is keywords describing the task
>that you are seeking to achive that you should be looking for (in Perl
>newsgroups). The keywords describing the task are not dependant on
>the choice of implementation language.
>
>How about 'CGI' and 'remote' in comp.lang.perl* on deja.com
>
>Judging by the subject lines the first 7 hits are fairly obviously not
>going to relvant.
>
>The 8th hit has a usless subject line "challenging problem" because
><paceman97@aol.com> was too selfish/arrogant/lazy to bother thinking
>of a good subject line for the thread. You'll have to read it to find
>out if it is relevant.
>
>You read it and you find it doesn't exactly answer you question but
>does mention in passing something called "LWP" that from context
>appears to be related to the answer to your question.
>
>> Once I know what module to use I think I can figure it out from there
>> with these 2 Oreilly books and man pages.
>
>Light bulb springs on above head: perhaps LWP is a module. (Actually
>it's a bundle of modules).
------------------------------
Date: Thu, 9 Nov 2000 23:09:28 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Running a remote CGI script through perl
Message-Id: <Pine.GHP.4.21.0011092308090.2995-100000@hpplus03.cern.ch>
On Thu, 9 Nov 2000, MrPaul wrote:
(quoting the excellent advice from 'nobull')
> I'm glad that there are people in the world like you that make life so
> pleasurable for others.
Some of us are, indeed.
You, on the other hand, head direct for the scorefile.
[and another jeopardectomy on the N.H.S]
------------------------------
Date: 09 Nov 2000 19:06:28 -0200
From: Jorge Godoy <godoy@conectiva.com>
Subject: Taint mode and file globbing
Message-Id: <kp66lwvorv.fsf@dagon.conectiva>
Hi!
I'm in troubles with a module I'm developing and that will be used
with several scripts. I need it to execute this code (or similar
code):
#!/usr/bin/perl -wT
(...)
my @deletion_list = (<*.htm>, <*.html>, <html/*.htm>,
<html/*.html>, <HTML.index>);
(...)
unlink @deletion_list;
(OK, I need to improve such globs, but this is just a draft of the
function that works with real data :-))
This fails the 'taint' check and I want to find a way to do the same
operation and make it tainted.
Can anybody help me?
Thanks in advance!
--
Godoy. <godoy@conectiva.com>
Departamento de Publicações Conectiva S.A.
Publishing Department Conectiva Inc.
------------------------------
Date: Thu, 09 Nov 2000 20:04:03 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: udp server - high volume - log switch
Message-Id: <TqDO5.278$Bf7.188635136@news.frii.net>
In article <t5uO5.1154$FG.62261@eagle.america.net>,
Garry Williams <garry@zvolve.com> wrote:
>On Thu, 09 Nov 2000 05:47:04 GMT, Chris Fedde
><cfedde@fedde.littleton.co.us> wrote:
>>In article <8udbg8$12d$1@nnrp1.deja.com>, <fw58959@hotmail.com>
>>wrote:
>...
>>
>> sub checkhup {
>> if ($GotHup) {
>> close LOG;
>> open (LOG, ">>log") or die "can't open log: $!";
>> }
>> }
>
> sub checkhup {
> if ($GotHup) {
> close LOG;
> open (LOG, ">>log") or die "can't open log: $!";
> $GotHup = 0;
> }
> }
>
Oops! thanks for the catch!
chris
--
This space intentionally left blank
------------------------------
Date: 09 Nov 2000 14:37:33 -0600
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: Use Eval to open file?
Message-Id: <m3snp0khki.fsf@dhcp11-177.support.tivoli.com>
Don Vaillancourt <donv@webimpact.com> writes:
> my $evaluation = "open(INDEX_HANDLE_$index_number, \"+<$table\"); my
> \$index_handle=*INDEX_HANDLE_$index_number; return \$index_handle;";
> my $index_handle = eval $evaluation;
Depending on your perl version, you could simply use the new
autovivification of filehandles:
open my $fh "+<$table" or die;
This will create a new filehandle each time it is called, with $fh has
a reference to it. Just save it somewhere and you're good to go.
--
Ren Maddox
ren@tivoli.com
------------------------------
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 4859
**************************************