[12083] in Perl-Users-Digest
Perl-Users Digest, Issue: 5683 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun May 16 07:07:29 1999
Date: Sun, 16 May 99 04:00:19 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 16 May 1999 Volume: 8 Number: 5683
Today's topics:
Re: Hash arrays armchair@my-dejanews.com
Re: Hash arrays armchair@my-dejanews.com
Re: Hash arrays armchair@my-dejanews.com
Re: Hash arrays armchair@my-dejanews.com
Re: Hash arrays (Sam Holden)
Re: Hash arrays armchair@my-dejanews.com
Re: Hash arrays armchair@my-dejanews.com
Re: Hash arrays armchair@my-dejanews.com
Re: Hash arrays (Sam Holden)
Re: Hash arrays (Sam Holden)
Re: Hash arrays armchair@my-dejanews.com
Re: Hash arrays (Sam Holden)
Re: Hash arrays (Sam Holden)
Re: Need help to modify email checker. <robbert@wethmar.demon.nl>
Re: Perl "constructors" armchair@my-dejanews.com
Re: Perl "constructors" <rra@stanford.edu>
Re: Perl "constructors" armchair@my-dejanews.com
Re: Perl "constructors" <rra@stanford.edu>
Re: regexp problem <robbert@wethmar.demon.nl>
Re: Saving regularly a web page (Bryant Fong)
Re: standard array and associative array (Bart Lateur)
Re: standard array and associative array (Bart Lateur)
Re: visual debugger for UNIX? (Reini Urban)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 16 May 1999 10:10:36 GMT
From: armchair@my-dejanews.com
Subject: Re: Hash arrays
Message-Id: <7hm5is$g2r$1@nnrp1.deja.com>
In article <slrn7js0mp.qlg.fl_aggie@stat.fsu.edu>,
fl_aggie@thepentagon.com wrote:
> On Sat, 15 May 1999 11:27:18 GMT, armchair@my-dejanews.com
> <armchair@my-dejanews.com>, in
>
> + So true Sam, very small brain. But nature balances things out and
I'm
> + very large elsewhere. Is that why you guys seem so testy - jealousy?
>
> Jealousy over a big mouth? Huh? I don't get it!
James, after reading the postings of these fellows, I can see where you
would form the opinion that they are worried about people having bigger
mouths than them. Some of them certainly do like to bray, and appear to
be quite proud of it.
>
> James
>
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: Sun, 16 May 1999 10:15:44 GMT
From: armchair@my-dejanews.com
Subject: Re: Hash arrays
Message-Id: <7hm5sg$g4p$1@nnrp1.deja.com>
In article <slrn7jsh8e.49a.sholden@pgrad.cs.usyd.edu.au>,
sholden@cs.usyd.edu.au wrote:
> On Sat, 15 May 1999 11:27:18 GMT, armchair@my-dejanews.com wrote:
> >In article <slrn7jpvfq.871.sholden@pgrad.cs.usyd.edu.au>,
> > sholden@cs.usyd.edu.au wrote:
> >> On Sat, 15 May 1999 04:02:06 GMT, armchair@my-dejanews.com wrote:
> >> >In article <7hh47d$14q$1@nnrp1.deja.com>,
> >
> >Thanks Sam. My "manual" is "Perl From the Ground Up" by Michael
> >McMillan, and it leaves off the (In a scalar context, returns the
> >number of keys).
>
> The fact that you don't use the official manual that comes with perl
> is not my problem. You mentioned perlfunc and claimed that adding
> this stupid entries() function would mean that people could read
> about it in perlfun. Since it is already documented in the perlfunc
> documentation for keys that seems a little stupid me.
If my not reading the Perl "manual" is not your problem, just what is. I
can tell something is really disturbing you. Maybe I can help. Talk to
me.
> >
> >
> >> RTFM. RTFM. RTFM, in fact even better, go and learn python. Your
brain
> >is
> >> not large enough to cope with perl.
> >
> >So true Sam, very small brain. But nature balances things out and I'm
> >very large elsewhere. Is that why you guys seem so testy - jealousy?
>
> I;m not jealous you can be assured of that. I just think you'd like
python
> much more, since it gives you much less freedom, and you seem to be
scared
> of freedom in a programming context.
As much as you are pushing Python, I am beginning to suspect that your
real name is Guido.
>
> --
> Sam
>
> Perl is the Cliff Notes of Unix.
> --Larry Wall
>
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: Sun, 16 May 1999 10:17:37 GMT
From: armchair@my-dejanews.com
Subject: Re: Hash arrays
Message-Id: <7hm601$g51$1@nnrp1.deja.com>
In article <q6ijh7.gp4.ln@magna.metronet.com>,
tadmc@metronet.com (Tad McClellan) wrote:
> armchair@my-dejanews.com wrote:
returned in
[good answer snipped]
Thanks Tad.
>
> --
> Tad McClellan SGML Consulting
> tadmc@metronet.com Perl programming
> Fort Worth, Texas
>
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: Sun, 16 May 1999 10:23:40 GMT
From: armchair@my-dejanews.com
Subject: Re: Hash arrays
Message-Id: <7hm6bc$gdo$1@nnrp1.deja.com>
In article <7hkblt$jrr@llama.swcp.com>,
hudson@swcp.com (Tramm Hudson) wrote:
> In article <7hjlcv$t2e$1@nnrp1.deja.com>, <armchair@my-dejanews.com>
wrote:
> [snip]
> > Here's a dime old fellow. Get a real computer, get a real
newsreader,
> > get a good cup of coffee.
>
> Pot, meet Kettle. You are running NT and posting from Deja News with
> a web browser -- hardly a real computer or newsreader by anyone's
> standards. Don't forget your multiple postings of many articles, poor
> line wrapping skills and overall lack of proper follow-up editing.
> But don't let that stop you from criticizing one of the most prolific
> and well written posters on Usenet as a whole.
Well I dislike Microsoft as much as the next person, but how did you
know I am on a computer that uses NT, or was it just a guess? I believe
I only multiple posted 2 or maybe 3 articles. At least one I actually
changed a line (hit browser back after posting so it technically was
different). As far as line wrapping, that is out of my hands and in
Dejanews, which you criticize. You will have to be more specific on
"overall lack of proper follow-up editing".
By the way, your prolific and well-written poster uses phrases like "you
have a C++ pole so far up your butt it is hitting your brain".
And "get a real computer, a real newsreader, a real..."
I just chose to reflect one back at him and your criticize me, and
praise him. Go figure.
> Maybe TomC will see this and get a good laugh, although I suspect he
has
> already kill filed this entire thread.
> --
> o hudson@swcp.com tbhudso@cs.sandia.gov O___|
> /|\ http://www.swcp.com/~hudson/ H 505.266.59.96 /\ \_
> << KC5RNF @ N5YYF.NM.AMPR.ORG W 505.284.24.32 \ \/\_\
> 0 U \_ |
>
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: 16 May 1999 10:35:24 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Hash arrays
Message-Id: <slrn7jt7rc.1nu.sholden@pgrad.cs.usyd.edu.au>
On Sun, 16 May 1999 10:23:40 GMT, armchair@my-dejanews.com wrote:
>
>Well I dislike Microsoft as much as the next person, but how did you
>know I am on a computer that uses NT, or was it just a guess?
I expect the following header gives it away quite clearly :
X-Http-User-Agent: Mozilla/4.51 [en] (WinNT; U)
>> --
>> o hudson@swcp.com tbhudso@cs.sandia.gov O___|
>> /|\ http://www.swcp.com/~hudson/ H 505.266.59.96 /\ \_
>> << KC5RNF @ N5YYF.NM.AMPR.ORG W 505.284.24.32 \ \/\_\
>> 0 U \_ |
>>
One little point though, you really shouldn't quote the .sig. Since it
is one thing you are almost certainly not commenting on.
--
Sam
I don't want Perl to be beautiful--I want you to write beautiful
programs in Perl.
--Larry Wall
------------------------------
Date: Sun, 16 May 1999 10:30:24 GMT
From: armchair@my-dejanews.com
Subject: Re: Hash arrays
Message-Id: <7hm6o0$gog$1@nnrp1.deja.com>
In article <m37lqa1mmr.fsf@joshua.panix.com>,
Jonathan Feinberg <jdf@pobox.com> wrote:
> armchair@my-dejanews.com writes:
>
> > I would definitely have to study real hard and long to find out that
> > a hash name inside an if test returns 0 if the has is empty.
>
> No, you'd have either to read any decent tutorial (the book _Learning
> Perl_ comes to mind) or to read the perl document "perldata", which
> states
>
> If you evaluate a hash in a scalar context, it returns a
> value that is true if and only if the hash contains any
> key/value pairs.
That only works if I can get from "a scalar context" to "if ( ) is a
scalar context". I probably would not have done that for a while. I
would have found entries() right away though.
>
> and which comes with perl.
>
> Good luck in your trolling.
Thanks.
>
> *plonk*
Thanks.
>
> --
> Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
> http://pobox.com/~jdf
>
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: Sun, 16 May 1999 10:25:03 GMT
From: armchair@my-dejanews.com
Subject: Re: Hash arrays
Message-Id: <7hm6dv$geb$1@nnrp1.deja.com>
In article <slrn7jshro.49a.sholden@pgrad.cs.usyd.edu.au>,
sholden@cs.usyd.edu.au wrote:
> armchair@my-dejanews.com wrote:
> >
> >As long as $num_elements = keys(%hash) doesn't create a temporary
> >intermediate array, I guess I am happy, as that syntax is no more
> >confusing than $num_elements = @array;
>
> So do some research and find out what it does. Or do you need to be
> spoon fed everything...
Are you truly contending that every Perl programmer should examine the
source code of Perl to find out how $scalar = keys %hash; is
implemented? Then what would you fellows hector people about?
>
> --
> Sam
>
> In case you hadn't noticed, Perl is not big on originality.
> --Larry Wall
>
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: Sun, 16 May 1999 10:27:10 GMT
From: armchair@my-dejanews.com
Subject: Re: Hash arrays
Message-Id: <7hm6hu$gft$1@nnrp1.deja.com>
In article <slrn7js0hj.qlg.fl_aggie@stat.fsu.edu>,
fl_aggie@thepentagon.com wrote:
> On Sat, 15 May 1999 11:22:08 GMT, armchair@my-dejanews.com
> <armchair@my-dejanews.com>, in
>
> + You said that before. What is it? Do you just keep hitting the send
key?
> + Here's a dime old fellow. Get a real computer, get a real
newsreader,
> + get a good cup of coffee.
>
> You obviously aren't cut out for perl...give it up, while you're still
> behind...
James, correctly if I'm wrong, but to be cut out for Perl you need a
supercilious rating of 7.89 or above, eh?
>
> James
>
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: 16 May 1999 10:42:51 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Hash arrays
Message-Id: <slrn7jt89b.1nu.sholden@pgrad.cs.usyd.edu.au>
On Sun, 16 May 1999 10:15:44 GMT, armchair@my-dejanews.com wrote:
>In article <slrn7jsh8e.49a.sholden@pgrad.cs.usyd.edu.au>,
> sholden@cs.usyd.edu.au wrote:
>> On Sat, 15 May 1999 11:27:18 GMT, armchair@my-dejanews.com wrote:
>> >In article <slrn7jpvfq.871.sholden@pgrad.cs.usyd.edu.au>,
>> > sholden@cs.usyd.edu.au wrote:
>> >> On Sat, 15 May 1999 04:02:06 GMT, armchair@my-dejanews.com wrote:
>> >> >In article <7hh47d$14q$1@nnrp1.deja.com>,
>
>> >
>> >Thanks Sam. My "manual" is "Perl From the Ground Up" by Michael
>> >McMillan, and it leaves off the (In a scalar context, returns the
>> >number of keys).
>>
>> The fact that you don't use the official manual that comes with perl
>> is not my problem. You mentioned perlfunc and claimed that adding
>> this stupid entries() function would mean that people could read
>> about it in perlfun. Since it is already documented in the perlfunc
>> documentation for keys that seems a little stupid me.
>
>
>If my not reading the Perl "manual" is not your problem, just what is. I
>can tell something is really disturbing you. Maybe I can help. Talk to
>me.
My problem is all these damn third years asking me questions all the time,
they even want there assignments to be marked and given back... Kids these
days...
But I'm sure you really didn't want to know...
>
>
>> >
>> >
>> >> RTFM. RTFM. RTFM, in fact even better, go and learn python. Your
>brain
>> >is
>> >> not large enough to cope with perl.
>> >
>> >So true Sam, very small brain. But nature balances things out and I'm
>> >very large elsewhere. Is that why you guys seem so testy - jealousy?
>>
>> I;m not jealous you can be assured of that. I just think you'd like
>python
>> much more, since it gives you much less freedom, and you seem to be
>scared
>> of freedom in a programming context.
>
>As much as you are pushing Python, I am beginning to suspect that your
>real name is Guido.
Some friends of mine would fgind that very humourous indeed... I've already
appologised for being such a rude, small minded, bigoted , jerk, and whatever
else so I won't again...
I like perl. I keep finding myself tutoring courses in which python gets
used and thus I have learnt a bit of python. Python is a bit
more demanding than perl, it restricts the programmer with the things that
python thinks are right (like indentation and OO for example). I think
you'd like python more than perl, since it is more consistant with an OO
system that is very core to the language (you mightn't write a new class in
a quick script, but you'll use an object or two).
I'm probably wrong, I often are. A significant amount of the time that
I'm wrong it's in a public forum of course. Knowing my knack you're
probably Larry Wall in disguise...
Anyway my real name's Sam - no it really is...
--
Sam
It has been discovered that C++ provides a remarkable facility for
concealing the trival details of a program--such as where its bugs are.
--David Keppel
------------------------------
Date: 16 May 1999 10:48:26 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Hash arrays
Message-Id: <slrn7jt8jq.46f.sholden@pgrad.cs.usyd.edu.au>
On Sun, 16 May 1999 10:27:10 GMT, armchair@my-dejanews.com wrote:
>
>James, correctly if I'm wrong, but to be cut out for Perl you need a
>supercilious rating of 7.89 or above, eh?
8.12 in fact
--
Sam
The very fact that it's possible to write messy programs in Perl is also
what makes it possible to write programs that are cleaner in Perl than
they could ever be in a language that attempts to enforce cleanliness.
--Larry Wall
------------------------------
Date: Sun, 16 May 1999 10:41:41 GMT
From: armchair@my-dejanews.com
Subject: Re: Hash arrays
Message-Id: <7hm7d5$h39$1@nnrp1.deja.com>
In article <926815016.915739@thrush.omix.com>,
zenin@bawdycaste.org wrote:
> armchair@my-dejanews.com wrote:
> : tchrist@mox.perl.com (Tom Christiansen) wrote:
> :> By reading or grepping the manpages, just like the rest of us.
What part
> :> of the standard Perl documentation included with each and every
Perl
> :> distribution did you happen to find less than clear on this matter?
> :
> : At the crime of repeating myself, I have been reading "Perl From the
> : Ground Up" and "Teach Yourself Perl in 21 Days" and did not see any
> : examples of discussion of how to get the number of items in a hash
in
> : their sections on hashes.
>
> What part of, "included with each and every Perl distribution"
did
> you not understand?
>
> The books you mentioned are simply that, books. They are *not*
the
> manual nore are they a replacement for it.
Okay, let's have a look see here. Someone says that was in the info on
keys blah blah in the "manual", and I respond that I had looked in a
book reference on keys which didn't same information as in the "manual"
(implying a recognition of what is in the manual), and then you come in
with some harangue about looking in the manual. Yeah, I can see why
Larry Wall tries to tie in his and his ancestors religious background
into discussions of Perl. I really can see it.
>
> : I hope you can find it in your heart to forgive me for not looking
at
> : FAQ4, where the answer is most easily found.
>
> No, sorry. There is no excuse for not looking in the FAQ,
> especially with the availability of tools expressly for it such
> as: `perldoc -q hash'.
Well then, I recommend time served along with 90 days community service
teaching Perl to disadvantaged youth as my punishment. I think you would
agree that the guillotine that Sam Holden has proposed is just too
extreme.
>
> --
> -Zenin (zenin@archive.rhps.org) Caffeine...for the mind.
> Pizza......for the body.
> Sushi......for the soul.
> -- User Friendly
>
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: 16 May 1999 10:50:49 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Hash arrays
Message-Id: <slrn7jt8o9.46f.sholden@pgrad.cs.usyd.edu.au>
On Sun, 16 May 1999 10:30:24 GMT, armchair@my-dejanews.com wrote:
>
>That only works if I can get from "a scalar context" to "if ( ) is a
>scalar context". I probably would not have done that for a while. I
>would have found entries() right away though.
Or you would use 'if (scalar %hash)' until you found out that an if
takes an expression, and that is scalar...
--
Sam
I would like to tell you that Perl is simple in its complexity. But some
people won't understand that. So pretend I didn't say that, unless you
do. --Larry Wall
------------------------------
Date: 16 May 1999 10:57:37 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Hash arrays
Message-Id: <slrn7jt951.46f.sholden@pgrad.cs.usyd.edu.au>
On Sun, 16 May 1999 10:25:03 GMT, armchair@my-dejanews.com wrote:
>In article <slrn7jshro.49a.sholden@pgrad.cs.usyd.edu.au>,
> sholden@cs.usyd.edu.au wrote:
>> armchair@my-dejanews.com wrote:
>> >
>> >As long as $num_elements = keys(%hash) doesn't create a temporary
>> >intermediate array, I guess I am happy, as that syntax is no more
>> >confusing than $num_elements = @array;
>>
>> So do some research and find out what it does. Or do you need to be
>> spoon fed everything...
>
>Are you truly contending that every Perl programmer should examine the
>source code of Perl to find out how $scalar = keys %hash; is
>implemented? Then what would you fellows hector people about?
No. One would read the docs on keys and find that it doesn't say either
way, but the fact that it mentions that it returns the number in a
scalar context might be some evidence that it doesn't always return a list
when then gets converted to a scalar. One would probably assume at first
that it didn't create a list since that would be rather innifiecient.
Then the FAQ on counting the number elements in a hash mentions
In void context it just resets the iterator, which is
faster for tied hashes.
which would imply that keys knows a bit about it's context and thus
should do the efficient thing.
Next would be to search the news archives and possibly www.perl.com.
Alternatively you could write a simple Benchmark and see if the
cost of $count = keys %hash; is O(n) or O(1) or O(n**2) or whatever.
I have not read the source code of perl (I've looked at bits of
it out of interest) and don't plan to anytime soon (or later).
Though I guess if you really had to know the answer the source
code would tell you (though I wouldn't want to know that much).
--
Sam
Another result of the tyranny of Pascal is that beginners don't use
function pointers.
--Rob Pike
------------------------------
Date: Sun, 16 May 1999 12:19:41 +0200
From: "Robbert Wethmar" <robbert@wethmar.demon.nl>
Subject: Re: Need help to modify email checker.
Message-Id: <926850334.4941.1.pluto.c3adf115@news.demon.nl>
----------------------------------------------------------------------------
------------
I can't quite see the second line being a complete Perl statement, but...
Here's what it does. The Perl code fragment:
s unless b ;
will execute s unless b is true. You can read more about unless at:
----------------------------------------------------------------------------
------------
correct, but also:
unless b s;
will execute s unless b is true, that way the 's' can be on the next line
wich wasn't copied into the message....
robbert
------------------------------
Date: Sun, 16 May 1999 09:48:25 GMT
From: armchair@my-dejanews.com
Subject: Re: Perl "constructors"
Message-Id: <7hm499$fbu$1@nnrp1.deja.com>
In article <926818805.230749@thrush.omix.com>,
zenin@bawdycaste.org wrote:
> armchair@my-dejanews.com wrote:
> >snip<
> : Where are the core concepts of Perl stated?
>
> In /usr/local/src/perl5.005_03/*.[ch]
That file doesn't exist on my system. Are you referring me to souce code
for the core concepts? Is that you Skippy?
>
> >snip<
> : Perhaps a majority are, and perhaps a majority of code that is
written is
> : never modified by anyone other than the author, but in the cases
where it
> : is, standardization and rules that allow compile time error catching
are
> : of great value.
>
> See the strict and fields man pages.
I have been using strict since seeing it recommended in this forum. I
will try and figure out fields.pm.
>
> >snip<
> : Wrong. I am using an array because I have created an object that
needs
> : to hold multiple scalars, one of which is total_attendees.
>
> Then use a hash.
>
> : I have no choice but to $rSelf->[10].
>
> And a hash failed you, how exactly?
>
> : You should have attacked me for not using a hash to store the data
where I
> : could have written $rSelf->{"total_attendees}.
>
> He did.
As I noted, in my post, which you deleted.
>
> : And surely a proponent of Perl, a language that you have just
described as
> : libertarian, so libertarian constructors can be of any name, would
not
> : actually be complaining about a simple user-defined variable
name????
>
> Just because particular code is allowed doesn't preclude it from
> being trash.
One man's trash is another man's gold. Once you tout the fact that "Perl
doesn't restrict how you think, code or setup a picnic table" you
shouldn't come back and say 'dude, that way is trash'. It seems quite
immature and capricious. No code that works can be thought of as trash,
although it can be marked down for readability/maintainability. And the
poster was complaing about what is often referred to as Hungarian
notation variable naming, something that was popularized by a legendary
programmer named Charles Simonyi, who wrote the first GUI word processor
at Xerox PARC before moving on to Microsoft. I would guess that a very
tiny amount of the people who look at that variable naming convention
could have written the first GUI word processor, and yet they will say
things like the poster did "Only an idiot would code like that" when
they see it. I am sure that many among us would join me in saying that
that type of thinking has no place in the Perl community where Art,
Common Sense, Linguistics and Computer Science converge.
> --
> -Zenin (zenin@archive.rhps.org) Caffeine...for the mind.
> Pizza......for the body.
> Sushi......for the soul.
> -- User Friendly
>
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: 16 May 1999 03:06:12 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Perl "constructors"
Message-Id: <yl675t1g8b.fsf@windlord.stanford.edu>
armchair <armchair@my-dejanews.com> writes:
> Your point about a solid suite of test cases being necessary to
> completely checkout any large project is well taken. But as studies
> show, the sooner that errors are caught, the cheaper and less negative
> it is to the project.
Agreed. I can just say that as a Perl programmer who has written six or
seven modules now and more scripts than I can count, including some
programs that involve several thousand lines of code, that I've not found
it to be a problem. The only place where I can see it being a major
problem is with object data, since that's the only place where one really
has to use a hash table and doesn't get the benefit of use strict, and in
that case "use fields" effectively solves the problem. It should come
with all recent Perls.
I should add that I don't think Perl is necessarily the best language for
writing very large programs, where by very large I mean 10,000 lines of C
code or more. If you can break that down into a bunch of seperate
programs that work together, that's another matter, and Perl can do quite
well. Similarly if you can break it down into a bunch of modules,
although they have to be very clear and very independent modules. But I'd
never write something like, say, emacs or Netscape in Perl. I find that
Perl quickly starts getting unweildy with *large* applications.
No language does *everything* well.
> And, the C designers decided to move away from allowing flexible and
> variable parameter passing, to enforcing strict parameter prototyping.
Actually, I'd highly recommend that you read Dennis Ritchie's essay on the
design of the C programming language. This isn't really true. C added
function argument *declarations* a bit farther down the road, but that's a
syntactic addition for compilers and error checking, not a new language
design element; it's not that all C functions took variable arguments of
random types before then. C has always been strongly typed. It's just
that the early declaration syntax didn't allow the compiler to easily
*check* that typing in function calls.
Perl, on the other hand, is *not* strongly typed, so this whole issue just
doesn't apply to it.
> Since Perl has added optional prototyping as well, I think that some top
> computer science people must feel that there is an advantage to catching
> the fact that a subroutine is being called incorrectly the first time it
> is compiled, rather than when it fails test case #15 during checkout.
Top computer science people believe all sorts of different things. I can
introduce you to a lot of top computer science people who think that Perl
has far too much typing and that everyone should use Lisp.
The concept of "calling a subroutine incorrectly" happens so amazingly
infrequently in Perl that I'm very surprised when I see it. It's just not
a problem that I ever seem to have when actually writing Perl code. I
think a lot of that is because Perl lets you casually throw around more
complicated objects like arrays and hashes and therefore it's much rarer
to have to pass six arguments into a function and remember that oh, that's
right, you added a seventh argument.
Plus, when there are a lot of options, Perl code generally goes to
accepting hashes with each option being a key and everything having
default values. That works pretty well.
The only time I ever use function prototypes is when I want to use the \@
or \% prototypes, which actually add new functionality to the language
that isn't possible without prototypes.
> But to really check at compile time you have to have variable typing.
For most Perl code, people who think they have to do variable typing are
worrying too much about things that Perl knows perfectly well how to deal
with all by itself.
> To handle this, many C++ programmers are now using m_ as a prefix on the
> names of member data. (e.g. m_numberOfItems) And as you mention below,
> there is a this pointer, and that could always precede the variable name
> as in this->items instead of items. In effect, the this pointer would
> function like the reference to the object of Perl.
Right. Perl essentially makes you do this->items all the time, because
member data isn't special. Perl makes much less of the Object than C++
does; very little of it is particularly special.
> It would seem that the only thing that makes it clear is if the
> programmer gives appropriately clear names to the references.
You have a point there. Still, I like $$self{items} better than just
seeing items and wondering where it came from. And C++ programmers don't
seem to use this->items.
> C++ has pointers, which are identical to Perl references - they store
> the address of other variables, and you dereference them to get at the
> data that is being referred to (or pointed to), which themselves can be
> complex data structures. You could look inside a C++ class and see only
> one member variable MyMapPointer *m_pMap; or it could be a pointer to an
> array MyArray *m_pArray; even though the class is actually representing
> all the organizations and employees of a company.
Yes, I know all that; I was writing C long before I was writing Perl, and
I've written some non-trivial things in C++. I don't see how this relates
to my point, though. You were complaining about having an object only
have one reference to data, and I disagree with that view of things. An
object in Perl can be a hash table, an array, or a few other things, and
can contain quite a bit of data directly without using any references at
all other than the object itself, like "this" in C++.
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: Sun, 16 May 1999 09:55:50 GMT
From: armchair@my-dejanews.com
Subject: Re: Perl "constructors"
Message-Id: <7hm4n6$ffa$1@nnrp1.deja.com>
In article <926817583.5320@thrush.omix.com>,
zenin@bawdycaste.org wrote:
> armchair@my-dejanews.com wrote:
> : tchrist@mox.perl.com (Tom Christiansen) wrote:
> >snip<
> : You strip out to much of the previous post.
>
> Good. Never quote that which is not pertinent, especially
> in USENET.
Unfortunately Zenin, the fellow stripped out that which was pertinent.
>
> : Try editing less, and answering more.
>
> Try reading more, and BS less.
This from a fellow who leaves in the part of my post where I say "How
come you didnt' suggest a hash"? and then takes out the part where I ad
"Oh, you did", and then responds with "He did" to the first question.
If I could quote someone only slightly less revered than Perl - "Judge
not, lest ye yourself be judged."
>
> :> No, that's wrong. Don't test for 0.
> :>
> :> if ($value) suffices for truth, and unless ($value) for falsehood.
This
> :> == 0 business is brain-damange.
> :
> : Why shackle someone's code style to your biases. Try and be more
> : libertarian, like Perl and Larry Wall
>
> In Perl TIMTOWTDI, yes. That does not however, preclude
particular
> ways from simply being wrong.
A way is wrong if it doesn't work, not if you don't like it. If you
don't like it it can only be characterized as undesirable. Hear me now,
and as your mind opens, believe me later.
>
> >snip<
> : Is raising and exception supposed to be the die function?
>
> Yes, and before you ask we spell "try" as "eval", and "catch" as
> "if".
>
> >snip<
> :> :Very expensive, not intuitive.
> :>
> :> Liar. Twice.
> :
> : As it turns out, only once. Someone has proclaimed it not expensive,
but
> : no sane man, woman or child would ever call it intuitive.
>
> In the context of Perl, it is completely intuitive. Perl is
> optimized for the user, not the student. If you want to learn
how
> to program go play with Pascal or BASIC.
As I have tried to imply, if not state, I am an experienced programmer,
just not in Perl.
>
> --
> -Zenin (zenin@archive.rhps.org) Caffeine...for the mind.
> Pizza......for the body.
> Sushi......for the soul.
> -- User Friendly
>
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: 16 May 1999 03:11:31 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Perl "constructors"
Message-Id: <yl3e0x1fzg.fsf@windlord.stanford.edu>
armchair <armchair@my-dejanews.com> writes:
> And the poster was complaing about what is often referred to as
> Hungarian notation variable naming, something that was popularized by a
> legendary programmer named Charles Simonyi, who wrote the first GUI word
> processor at Xerox PARC before moving on to Microsoft.
I know where it came from. I've read his writings on the topic. I used
Hungarian notation for years myself and then decided it wasn't buying me
anything at all beyond making my variable names longer and harder to read.
I'm not dissing it without practical experience.
In fact, Perl has a form of Hungarian notation built in, just enough to
not be as annoying and actually be somewhat useful. Adding Hungarian
notation on *top* of that strikes me as redundant and ugly.
> I would guess that a very tiny amount of the people who look at that
> variable naming convention could have written the first GUI word
> processor,
That doesn't mean he's good at coding style decisions, just that he's good
at writing applications.
> I am sure that many among us would join me in saying that that type of
> thinking has no place in the Perl community where Art, Common Sense,
> Linguistics and Computer Science converge.
Please argue for yourself. People who try to make their arguments sound
better by inventing other people who also support them sound like they're
trying to get support from imaginary friends.
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: Sun, 16 May 1999 12:08:06 +0200
From: "Robbert Wethmar" <robbert@wethmar.demon.nl>
Subject: Re: regexp problem
Message-Id: <926850334.4941.0.pluto.c3adf115@news.demon.nl>
>$text=~s/\b([b-df-hj-np-tv-z]+)([^\']*)/$2$3$1/gi ;
>Perl somehow matches that apostrophe and consonant after it as a new
>word, I think.
I agree! The part ([^\']*) machtches anything that's not a single quote,
INCLUDING SPACES. Wat you actually mean is match 'word charactars', but not
quotes, until a word boundary. (That is, if perl doesn't consider a qoute a
word boundary) Something like:
$test="this isn't a word but this is a bit more to see if it's working";
$test=~s/(^|\s)([aeiou]\S*?)(?=\s|$)//ig;
print "$test\n";
will give you: (remove te words you don' want)
this word but this bit more to see working
another option is something like:
$test="this isn't a word but this is a bit more to see if it's working";
$test=~s/(^|\s)([^aeiou]\S*?)(?=\s|$)/$1\[$2\]$3/ig;
print "$test\n";
wich will give you: (insert [ ] brackets around the words you want)
[this] isn't a [word] [but] [this] is a [bit] [more] [to] [see] if it's
[working]
the code has been tested and was funcional on my machine,
greetings,
robbert wethmar
ps: i wrote:
(That is, if perl doesn't consider a qoute a word boundary)
and i know now: Perl does!
------------------------------
Date: Sun, 16 May 1999 03:15:49 -0700
From: buttmunc@uclink4.berkeley.edu (Bryant Fong)
Subject: Re: Saving regularly a web page
Message-Id: <MPG.11a83aaf6d422d539896a0@news.berkeley.edu>
It's easier with unix crontab, but I think windows system agent will do
it? In windows 98 there's a scheduled tasks button, too..
In article <373E93F1.559F24C4@csi.com>, amig@csi.com says...
> Hi,
>
> Thanks for your suggestion.
>
> I am sorry, I think I have not explained clearly what I wanted. I know
> getprint, but I don't know how to launch it automatically each hour -
> for instance, if I want to save a page of news (Reuters, Wired, etc.) on
> my server each hour, but with the possibility of sleeping and going to
> holidays sometimes ...
>
> So perhaps my question is: how can I launch a perl program regularly on
> my Windows system ? Perhaps it's not the appropriate newsgroup...
------------------------------
Date: Sun, 16 May 1999 10:02:40 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: standard array and associative array
Message-Id: <373f9389.845954@news.skynet.be>
bing-du@tamu.edu wrote:
>I need to write a sub routine that is able to handle both standard array
>and associative array.
>
>If the parameter passed in is a standard array, then convert it to some
>sort of associative array first and then continue processing. If the
>parameter passed in is already an associative array, then skip
>the conversion step and continue processing.
You could do it the other way around: pass a hash ("associative array")
to a sub, and it will get turned into a simple array, one key and one
(it's) value every time. Of course, this would be a costly operation if
you actually turn a hash to an array to a hash again.
If the array is already formatted as a hash, you could convert it to an
anonymous hash on the call.
@ary = qw(one 1 two 2);
test( { @ary } );
%hash = ( un => 1, deux => 2);
test(\%hash);
sub test {
my($hash) = @_; # hashref
print "test:\n";
foreach (sort keys %$hash) {
print " $_: $hash->{$_}\n";
}
print "-*-*-\n";
}
In that case, it's safest to do at least
use strict qw(refs);
either at the front of the sub, or at the start of the script.
Bart.
------------------------------
Date: Sun, 16 May 1999 10:04:01 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: standard array and associative array
Message-Id: <374197ec.1969061@news.skynet.be>
Larry Rosler wrote:
>The most effective way to convert an array to a hash is by means of a
>hash slice.
Oh yeah. It's been a long time since our attention was drawn to that
fact.
;-)
Bart.
------------------------------
Date: Sun, 16 May 1999 10:40:10 GMT
From: rurban@sbox.tu-graz.ac.at (Reini Urban)
Subject: Re: visual debugger for UNIX?
Message-Id: <373e9dc4.2195837@judy>
emacs, xemacs, ptkdb
--
Reini
------------------------------
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 5683
**************************************