[13096] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 506 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 13 15:07:14 1999

Date: Fri, 13 Aug 1999 12:05:13 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 13 Aug 1999     Volume: 9 Number: 506

Today's topics:
        CGI and Blat - Help! imark@csource.net
    Re: Compare Two FILES <cassell@mail.cor.epa.gov>
        getting dimensions of JPEG image on Win32 <John_Hyer_Bercaw@hotmail.com>
    Re: getting dimensions of JPEG image on Win32 <cassell@mail.cor.epa.gov>
    Re: HARASSMENT -- Monthly Autoemail <Bill@fuckyou.co.uk>
    Re: I guess this is a Misc question: Cgi-bin <newsgroup@bigwig.net>
        Looking for gibberish generator (Kim Eggleston)
    Re: Perl, SQL, and O'Brain (Malcolm Ray)
    Re: Please help, DBI : statement handler <pfau@maherterminals.com>
        Program writes to text file twice or more (newbie) zchon@my-deja.com
    Re: Program writes to text file twice or more (newbie) <makkulka@cisco.REMOVETHIS.com>
    Re: Sending mail to "QuestionExchange" <flavell@mail.cern.ch>
    Re: ssi passing params with exec <webmgrNOS@agilitysystems.com>
    Re: Tom Christiansen "Perl Cookbook" support@gethits.com
    Re: Traversing of datastructure <makkulka@cisco.REMOVETHIS.com>
    Re: Why use Perl when we've got Python?! <jstevens@basho.fc.hp.com>
    Re: Why use Perl when we've got Python?! <jstevens@basho.fc.hp.com>
    Re: Why use Perl when we've got Python?! <jstevens@basho.fc.hp.com>
    Re: Win32::Process (Anno Siegel)
        Writing lines to file twice or more (newbie question) zchon@my-deja.com
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: Fri, 13 Aug 1999 18:28:27 GMT
From: imark@csource.net
Subject: CGI and Blat - Help!
Message-Id: <7p1o3g$9cj$1@nnrp1.deja.com>

Hi,

I really hoping someone might be able to help me or point me to someone
who
can.  I'm running a shopping cart cgi script on a secure WinNT server.
Unfortunately I'm getting dick all tech support from the makers of the
shop cart software. We have Blat 1.8.4 installed and it runs fine from
the command line. The cgi script runs fine until I submit the order then
I get the error "Can not send mail. Please check mailer specification".

It seems as though the script can't find Blat to mail the order but I
know next to nothing about cgi. The shop cart software automatically
sets the script up for use with Blat. All I have to do is specify the NT
Mail Server for which we're using the mailer on our regular Unix server.
I thought maybe this was the problem but Blat runs fine from a command
line. Blat is there to redirect the mail from the NT server to to the
mailer on the Unix server, correct?

At this point I'm ready to pay anyone who can figure out why the script
won't mail out the order.
I'm going to lose a client any day now if I don't get this figured out.
I'm not sure if the problem is with the cgi script (which is supposedly
all set up for Blat) or with a server configuration.

If your interested in helping let me know and I'll send you the script
and other related info. Thanks. Looking forward to hearing from you.

Derek Stewardson



Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Fri, 13 Aug 1999 11:30:05 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Compare Two FILES
Message-Id: <37B4642D.AF2B17E8@mail.cor.epa.gov>

Tom Christiansen wrote:
> 
>      [courtesy cc of this posting mailed to cited author]
> 
> In comp.lang.perl.misc, "Romiko" <rvdd@iafrica.com> writes:
> :I have been trying to write a script that compares two similar files and
> :updates the changes , I have been trying for two days and cannot get it
> :right.
> 
> Learn about the diff and patch, and maybe the cmp, commands.

Or, alternatively, read about the DBI and DBD::* modules,
and consider putting this into a *real* database so you can
do this in a less risky manner.
 
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Fri, 13 Aug 1999 11:02:57 -0700
From: "Hyer Bercaw" <John_Hyer_Bercaw@hotmail.com>
Subject: getting dimensions of JPEG image on Win32
Message-Id: <37b45d09@news.nwlink.com>

I have a CGI program that needs to create thumbnail images on the fly. I
don't need to improve the download time, I just need to fit them on the
page. I would like to scale them proportionally so that they don't end up
looking weird.

Does anyone know how to have a PERL script figure out the X and Y dimensions
of a JPEG image?

Thanks,

Hyer




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

Date: Fri, 13 Aug 1999 11:40:58 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: getting dimensions of JPEG image on Win32
Message-Id: <37B466BA.2F82310D@mail.cor.epa.gov>

Hyer Bercaw wrote:

> Does anyone know how to have a PERL script figure out the X and Y dimensions
> of a JPEG image?

Have you looked at the Image::Size module available at CPAN ?
[If you don't know what CPAN is, look in the FAQ for info.]

Also, Benjamin Franz posted a thumbnail-ing program in this
newsgroup.  You can find it in the archives as deja.com .

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


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

Date: Fri, 13 Aug 1999 20:54:24 -0700
From: William Pettrey <Bill@fuckyou.co.uk>
Subject: Re: HARASSMENT -- Monthly Autoemail
Message-Id: <37B4E870.7305@fuckyou.co.uk>

Uriel Wittenberg wrote:
> 
> This comp.infosystems.www.authoring.html participant appears to have
> opted to openly harass me -- by a monthly autoemail of his message --
> in order to make me conform to his idea of correct style in posting.
> 
> Regardless of anyone's position on posting style, I would hope just
> about everyone understands the vindictive and antisocial nature of
> such behavior.
> 

Ya, I think everyone has received one of these messages from the local
asshole Tom Christenson. Just block his address, I did.


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

Date: Fri, 13 Aug 1999 18:56:53 +0100
From: "Ben Quick" <newsgroup@bigwig.net>
Subject: Re: I guess this is a Misc question: Cgi-bin
Message-Id: <37b47485.0@news2.cluster1.telinco.net>

J. Moreno wrote in message
<1dwg0ce.z5av0f1vr82f6N@roxboro0-0028.dyn.interpath.net>...
>Ben Quick <newsgroup@bigwig.net> wrote:
>
>  [John Moreno wrote]
>> >Asking off topic questions in the first place is frequently considered
>> >rude -- the faqs and other documents are quite clear on what is
>> >appropriate.
>>
>> I read the faq, it didn't (to my recolection) say do not ask about file
>> permissions
>
>No, but section 2 of the faq (Obtaining and Learning about Perl) says:
>
>comp.lang.perl.misc               Very busy group about Perl in general


The general part is very none specific. Maybe a re-wording is on order?

>That seems fairly clear to me -- it doesn't say "group about file
>permissions" or "group about unix" or "group about baseball".


Fair, but it also doesn't say the group isn't about file permissions. I know
it was off topic. I only found out after my post though

>(But this does bring up a point -- there is an excellent faq about perl,
>but not for the NEWSGROUP, perhaps a faq for the newsgroup is in order?)


I think that would be a very good idea. The faq is currently not really
about this group

>> >This and other off topic questions have been asked before and people are
>> >tired of dealing with them and so are easily annoyed (which goes back to
>> >the first reason because asking the question in the first place is
>> >considered rude).
>>
>> Ok, so off topic posts may be frequent. But as I've already said in
another
>> post, I am in a group that always get's the same old questions. We answer
>> them *polietly* which is the key. It's not hard to be polite
>
>It's your privilege to answer any way you like, extend the same
>privilege to others.


I don't understand.

>If you want to improve the "tone" then stick around and give polite
>answers.

I still don't understand. All I ask is for politness.

>> >Lots of people feel that such answers encourage people to post off topic
>> >questions here "well, I got an answer last time", "Joe User got a good
>-snip-
>> >Here's a general usenet hint -- when you say something in any new (to
>> >you) newsgroup and have one or more people point out that your post is
>> >off topic or otherwise inappropriate the CORRECT response is to
>> >apologize -- you may if you wish ask for direction to a more appropriate
>> >group, but you don't argue about it.
>>
>> I never argued that my post was *on* topic, I just pointed out that
saomeon
>> should know the answer. If no one did, all that had to be done was
politely
>> point me to the right group
>
>"Who has the season homerun record?" Most people here will know the
>correct answer --  the point is that politely giving the right answer or
>pointing to the right newsgroup gives the impression that the question
>was reasonable and it was OK to ask it.


No. Giving the answer would imply it is ok to aks. Pointing to the right
group would imply that where the question was asked was the wrong place

>It's not reasonable and it wasn't OK to ask it.


Fine

>> >If someone says you should have included a joke, then fine you should
>-snip-
>> >know the answer and it wouldn't hurt them to help you  -- you say
>> >"sorry" and then try to get along.
>>
>> I have never said I am right and you are wrong. I accept that I am fairly
>> new to perl and most people here know more than me. So, I'm sorry I don't
>> see your point there
>
>Here's what you had to say in your first response to criticism....
>
>] Well I'm sorry for being off topic. But to be fair, everyone (if not
>] most) here should know what the answer to my question is. It's only 3
>] numbers that you needed to post
>....
>] THANKYOU! You took all day to reach the answer. But at last
>
>You went through and point by point tried to justify yourself,

No, I commented on what I thought of any points raised

>and then
>when you got to the answer you were sarcastic about it.


And a little sarcasm is hurting people how? At least I'm always polite

>You were being chewed out for bad behavior, if you acknowledge that your
>behavior was bad then you shouldn't object to being chewed out.


My "behavior" has not been bad. I posted an off topic question. I
appologised.

>A "My mistake, I thought it would be OK to ask here"  followed by "Thank
>you, I appreciate it very much" (snipping everything in between).


As would a
"Sorry, you're in the wrong group. Try in ..."
or
"The answer is... but infuture forr this type of question ask in..."

>-snip-
>> Now, please could you let it drop.


>Sure.


Thankyou

>--
>John Moreno




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

Date: Fri, 13 Aug 1999 13:32:19 -0500
From: kim_eggleston@yahoo.com (Kim Eggleston)
Subject: Looking for gibberish generator
Message-Id: <MPG.121e20a9702c2a47989684@news.jump.net>

Hello there,

I am looking for a perl script which generates "fake" text for use in 
creating publishing mock-ups.  I don't want just random characters but 
something that looks like actual english.

Please let me know if you have any idea where I might find something like 
this or some starter code to use.

Thanks,
-Kim


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

Date: 13 Aug 1999 18:05:14 GMT
From: M.Ray@ulcc.ac.uk (Malcolm Ray)
Subject: Re: Perl, SQL, and O'Brain
Message-Id: <slrn7r8niq.b8l.M.Ray@carlova.ulcc.ac.uk>

On Fri, 13 Aug 1999 14:46:04 -0300, kayec <delete.the.nospam.kayec@gov.ns.ca>
wrote:
>I have a script that sets up users in a database, they are asked to supply
>Fname, Lname, phone.... etc. etc.
>
>I haven't had a problem until a guy named Scott O'Brain tried to create an
>ID.

How inconsiderate of him!

>Because i used single quotes for the SQL data his last name obviously
>messes this up.
>
>I tried to use double quotes event escaped them (\") but than the SQL
>statement didn't work.
>
>$sql = "INSERT INTO table1 (id,pw,fname,lname,enumber)
>VALUES
>('$input{\"id\"}','$input{\"pw\"}','$input{\"fname\"}','$input{\"lname\"}','
>$input{\"enumber\"}';";
>
>$database->Sql($sql);
>
>
>Surely i'm not the first person to run into an O'Brain....
>HELP !!!!!
>thanks,
>kayec

Do 'perldoc DBI' and take a look at the 'quote' method.  Given a string
in $name, the following line:

my $quoted_name = $dbh->quote($name);

will give you a correctly-quoted equivalent in $quoted_name, which you
can plug into an insert.

You've just learned an important lesson: never trust data entered by a user
to match your expectations.  Expect all user input to be hostile and
potentially fatal to your program, and code accordingly.  Read up on the
-T flag, and think about how you could use it.
-- 
Malcolm Ray                           University of London Computer Centre


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

Date: Fri, 13 Aug 1999 14:46:34 -0400
From: Thomas Pfau <pfau@maherterminals.com>
Subject: Re: Please help, DBI : statement handler
Message-Id: <37B4680A.F8DCD15B@maherterminals.com>

When matching against a list of values, use 'IN', not '='.

Your query should be
sth3 = $dbh->prepare(q(select id from table where (name IN ?))) ...

amita_rohatgi@my-deja.com wrote:
> I am executing the following piece of code which is a part of my
> program accessing the Oracle database.
> This code fetches only one id from the table though there are five ids
> it should fetch.
> 
> $sth3 = $dbh->prepare(q(select id from table where (name = ?)))  || die
> $dbh->errstr;
> 
> @arr = split(/,/,$scalar);
> foreach $item(@arr){
>   print"The cities are @arr\<BR\>";  //outputs the names of 5 cities
>   $sth3->execute($item) || die $sth3->errstr;
>   while( @id= $sth3->fetchrow()) {
>      print "Channel ID is : @id\<BR\>";  //output only one id
>   }
>   sth3->finish();
> }
> 
> die $sth3->errstr if $sth3->err;
> 
> But when I hardcode the values of  name in the array like this
> @arr = ("Sanjose", "SantaClara", "Sunnyvale", "Fremont", "Cupertino");
> I get all the five ids of the cities from the table. Please help.
> ...

-- 

Thomas Pfau
pfau@maherterminals.com
aka pfau@eclipse.net
http://www.eclipse.net/~pfau/


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

Date: Fri, 13 Aug 1999 18:24:03 GMT
From: zchon@my-deja.com
Subject: Program writes to text file twice or more (newbie)
Message-Id: <7p1nra$91s$1@nnrp1.deja.com>

  I am working on a text formatting program where I read from I one text
file, stick the large string into an array and then format it.  Then I
stick the formated array back into a large string and write the string
to another text file.  The problem is that when I finish running the
program and look at the text file it has written the first line twice,
the second line twice, third line twice, forth line three times and so
on without a pattern I can see.  The file I am reading the data from
does have some blank lines in between the data (ex:

data

data

data

data


data

  Any help would be greatly apperciated (This is my first really perl
program, no way like learning how to swim then by being thrown in the
deep end) Thanks in advance
                   Sean


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Fri, 13 Aug 1999 11:49:28 -0700
From: Makarand Kulkarni <makkulka@cisco.REMOVETHIS.com>
Subject: Re: Program writes to text file twice or more (newbie)
Message-Id: <37B468B8.C8F83DD8@cisco.REMOVETHIS.com>

[
zchon@my-deja.com wrote:
> The problem is that when I finish running the
> program and look at the text file it has written the first line twice,
> the second line twice, third line twice, forth line three times and so
> on without a pattern I can see. 
]

Post your program and only then can someone help.
Also you made a duplicate posting of this question.
Please try to cancel your other post.

--


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

Date: Fri, 13 Aug 1999 19:23:46 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Sending mail to "QuestionExchange"
Message-Id: <Pine.HPP.3.95a.990813191713.5423F-100000@hpplus03.cern.ch>

On 13 Aug 1999, Anno Siegel wrote:

> >Is anyone feeling robust enough to write up these observations and
> >put their heads above the net-abuse group parapet?
> 
> Oh dear.  Is there any useful dialog going on on n.a.n-a.usenet?

That's what I meant about the "parapet".

> A quick look shows only hysterical flamewars, but that are of course
> the big threads.

That group needs a strong filter and even stronger nerves, but there's
some tiny crumbs of gold amongst the dross.  Aside from news admins
mailing lists, I don't know another place that the problem would be
on-topic.  But as you'd expect, the abuse groups attract abusers.

all the best



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

Date: Fri, 13 Aug 1999 14:48:51 -0400
From: Paul Alcock <webmgrNOS@agilitysystems.com>
Subject: Re: ssi passing params with exec
Message-Id: <37B46893.600D91B2@agilitysystems.com>

Solution found thanks to Joshua.
Just in case others are looking for it....
Correct code for use on an apache server is...
    <!--#include virtual="/somedirectory/some.cgi?param1+param2" -->
    The virtual path must not include either "http" or the Root of the
path.
    ie. it should only be the path from the root of the domain visible to
the world.
Paul

Paul Alcock wrote:

> Anyone know a solution to this?
> In an shtml document file I have successfully executed a cgi using the
> exec command
> <!--#exec cgi="/cgi-local/rc_ASI.cgi" -->
> That works fine, but if I try to pass any parameters, such as...
> <!--#exec cgi="/cgi-local/rc_ASI.cgi?param1+param2" -->
> The exec cgi fails with a printable error.
> [an error occurred while processing this directive]
>
> Would appreciate your response.
> Thanks.
> Paul ps if answering directly the get rid of the N the O and the S
> before @ in my address.



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

Date: Fri, 13 Aug 1999 18:50:25 GMT
From: support@gethits.com
Subject: Re: Tom Christiansen "Perl Cookbook"
Message-Id: <37B46A83.94900B7B@gethits.com>



Malcolm Ray wrote:
> 
> On Fri, 13 Aug 1999 09:56:00 -0400

> Sometimes even the best books are wrong!  When there's a discrepancy,
> always trust the module's own documentation.

Thanks for confirming this. After multiple tests using both
codes, I had to come to the conclusion that the book must
be wrong since the module's author's method worked and "Cookbook's"
didn't (everything else remaining constant of course). Even
the great ones can err!

Darryl


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

Date: Fri, 13 Aug 1999 10:55:59 -0700
From: Makarand Kulkarni <makkulka@cisco.REMOVETHIS.com>
Subject: Re: Traversing of datastructure
Message-Id: <37B45C2F.4E1DF36B@cisco.REMOVETHIS.com>

[
> Hi, I have a datastructure which I want to traverse. Example:
> 
> $self->{os}             = 'solaris';
> $self->{osVersion}      = '7';
> $self->{nodeImportant}  = 5;
> $self->{heartbeat}      = 300;
> 
> I want to traverse the '$self'-object and get a key and value pair as
> if it were a traditional hash (I can not substitute it with a
> traditional hash). Pseudo code and the wished for results:
> 
>   foreach $key (keys $self) {
>       print "$key = $self->{$key}\n";
>   }
]
Use each() like this -
    while (($key,$value) = each %self) {
        print "$key=$value\n";
    }
-


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

Date: Fri, 13 Aug 1999 12:29:38 -0600
From: "John W. Stevens" <jstevens@basho.fc.hp.com>
Subject: Re: Why use Perl when we've got Python?!
Message-Id: <37B46412.B78F60F4@basho.fc.hp.com>

Tom Christiansen wrote:
>
> :particularly if you include the time it
> :takes to debug the code.
> 
> This smells very much of a Pascal programmer levelling criticism on a C
> programmer because C allows you to have unbounded pointers, type casts,
> and unchecked arrays.  The complaint was always "but think of how long
> it takes you debugging those core dumps!"

Actually, a valid criticism, but not due to debugging through
core dumps.

Buffer overruns, resource allocation tracking and side-effects are
the most common cause of C problems, and they also present some
of the biggiest failure analysis and debugging challenges.

(The static keyword exists for a reason, so USE IT!) ;->

Note that one commentator estimated that between 72 and 93 percent
of all existing C programs that use dynamic memory, have memory
leaks.

Pointers, also, make certain types of compiler optimization very,
very difficult.

> :The first thing that hit me with Perl is that different types of
> :variables require different special characters to identify them,
> 
> No, it's not like BASIC.  Perl has only three basic types: scalars,
> arrays, and hashes.  If I recall, there were dialects of BASIC in which
> you distinguished between integer and string values.  Perl doesn't
> distinguish between the values.  Instead, it distinguishes between
> whether something is singular or plural in nature.
> 
> Consider the following Python code, which illustrates the three types:
> 
>     a = 10
>     b = ["alpha", "beta", "gamma"]
>     c = { "fred" : "wilma", "barney" : "betty" }
> 
> To access elements, you use
> 
>     print b[0]
> 
> to get alpha, and yet despite the obvious analogy, you do not use
> 
>     print c{"fred"}
> 
> But rather
> 
>     print c["fred"]
> 
> You use one syntax for initialization, but a complete different one for
> access; this is inconsistent.

A valid criticism.  One I also find personally irritating.

> You cannot tell which fundamental kind
> of thing a, b, and c is just by looking at it.

True, but not necesarily a valid criticism.  Python is an OO
language.  Python behavior is more correct than Perl, for the OO
world.

> And it gets better
> when you pull in tuples.
> 
>     d = ("one", "two", "three")
> 
> What is that?  It's a constant list.  You access is using
> 
>     print d[0]
> 
> The differences in access between b, c, and d are hard to see.

But, once again, not only is this not a valid criticism but in
point of fact Python is more correct than Perl for this
example.

What you seem to be complaining about is called "polymorphism"
in the OO world.

Accessing an item out of an instance of a container class
*SHOULD* be polymorphic.

> And even worse, consider this:
> 
>     e = ("unity")
> 
> Is that a tuple or a single value?  It's a single value.  If you
> want a tuple, you have to use something like
> 
>     e = ("unity",)

This criticism I agree with.  And again, the above is one I
personally find irritating.

The only excuse for this is the simple fact that parser
technology, plus OO, plus a bad choice for tuple delimiter
characters all combined together.

> Python holds plenty of inconsistencies and surprises waiting
> to assault the sensibilities of the Perl programmer.  This isn't
> a one-way street.

True.

But in a test where programmers are ignorant of each, Python is
the prefered choice . . . *EXCEPT* where the programmers were
experienced C programmers.

> Just for kicks and grins, try firing up
> an interactive Python interpreter and using your mouse to cut and
> paste those lines.  Here there are all together:
> 
>     a = 10
>     b = ["alpha", "beta", "gamma"]
>     c = { "fred" : "wilma", "barney" : "betty" }
>     print "a is" a
>     print "b nought is", b[0]
>     print "c fred is", c["fred"]
> 
> Go ahead.  Grab it all with your mouse and punch it all it.  You can't
> do it.  You get the mysterious error
> 
>       File "<stdin>", line 1
>         a = 10
>         ^
>     SyntaxError: invalid syntax
> 
> Why is that?  Oh, because it's an "invalid syntax".  Cool message, dude.
> What the heck does it mean?

Agreed.  "Syntax error" doesn't cut it.  The above result is another
of my pet peeves.

> The reason, of course, is because the leading white space changed the
> syntax!  I cannot believe that the distaste you hold for using in Perl
> dollars to specify variables or differently using [] to access an array
> but {} to access a hash can possibly compare with the abhorrence that
> fills a Perl programmer when he realizes that the number of spaces
> at the front of the line is *syntactically significant*.

It bothered me, too, at first.  Now, after using it for a while, I
realize just how important and valuable this is.

Due to this feature alone, Python programs are easier to read by
non-authors than Perl programs are.

Been there, tested it myself.

IMHO, your complaint really devolves into: "I am not used to it,
therefore
I don't like it".

Since most progammers already have been trained in the importance
of, and how to actually do, proper indentation of their source
code, the change from "should" to "must" is less traumatic than
you make it out to be.  Get burned once, and you don't forget.

I freely admit, every new Python programmer does get burned once,
though.

> To the Perl programmer, or the C programmer, or the Java programmer, or
> the Pascal programmer, or the Modula programmer, or the Lisp programmer,
> or the BASIC programmer, or just about *anyone*, Python seems in this
> respect to be more of a rebellion against good language design than
> something with a sane design.  What happened to the lessons in language
> design of the last thirty years?  It's been a long time since the number
> of spaces mattered so much.  Happy languages like FORTRAN come to mind.

Excuse, but this is a bad comparison.  Columnarization requirements
existed
in Fortran to fit the limits of the compiler technology available at the
time.
Indentation requirements exist in Python to fit the needs of the
programmer.

In point of fact, some of Python's features are the direct result of the
last thirty years of language design.

> Guido has his justifications for this, but they will not sway someone
> until they've sufficiently embraced Python that they can overlook this.

Or, not overlook, but simply to understand how very nice this
requirement is.

The very first time you have to look at a library file. . . enforced
indentation will win you over.

Mind you, I wish that Python *ALSO* required block delimiters, and that
the tab-to-space translation was either defined by the language, or
that the use of spaces in indentation were forbidden altogether.

Every language has it's design flaws.

> My point is that non-Python programmers find Python filled with plenty
> of counterintuitive idiosyncrasies.

There are, indeed, some.  Not at many as with Perl, though.
(Not just a personal opinion: I've been told this by a number
of my students).

And a lot of the gotchas in Perl getcha again and again, unless
you use it constantly.

> When you hear non-Python programmers complaining of what they see in
> Python as stupid or wrong or ugly or backward-seeming, you will be quick
> to point out underlying reasons such as those listed above.

Actually, I rarely hear such comments from people who've used Python for
any length of time.

I do hear such comments, but most come from non-users.

New users usually find the following idiosyncracies (sp?) of Python
to be the most disturbing:

1) Indentation is meaningful.
2) Name spaces (read that section of the manual twice, people!)
3) The difference between *BEING* something, vs. storing a
   reference to something.
4) Immutable vs. mutable.

In just about that order, too.

> But I doubt,
> however, that you have yourself ever analysed how your *own* adverse
> reactions to C or Perl are elicited by the same unconscious prejudices and
> bigotries as irritate you when they are applied by others toward Python.

I, personally, have analysed why I prefer Python to Perl for most tasks.

It comes down to the issue we discussed once before: Python is the
better language for
OO, and I write OO most of the time.  I know you disagree.  But my
students,
in general, also believe that Python is a better OO scripting language
than
Perl.

This is due, IMO, to one of those language design lessons you
refered to earlier.

John S.


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

Date: Fri, 13 Aug 1999 12:53:55 -0600
From: "John W. Stevens" <jstevens@basho.fc.hp.com>
Subject: Re: Why use Perl when we've got Python?!
Message-Id: <37B469C3.52DBA9A4@basho.fc.hp.com>

John Porter wrote:
> 
> In article <37B28649.9C7F0C1E@NOSPAM.strs.co.uk>, Ian Clarke wrote:
> >
> >I am not so sure that Perl is "quicker" than Python.
> 
> Well clearly, since you don't know Perl, you're really not qualified
> to make this kind of judgement.

I, however, know and use both.  I am slowly shifting to using more
Python
than Perl as Python adds the stuff I need (PCRE is a god send).

Objectively, though:

For the same kinds of tasks, coded in the same way, Perl and
Python run at about the same speed.

In *general*, however, Python programs will run slower due to messaging
overhead (this may change if/when more Perl programmers start writing
OO Perl).

For example:

Since RE's are built right into Perl, while they are an extension
module in Python, simple text processing that has a heavy dependency
on RE's will run much faster as a Perl program than as a
Python program.

When I am writing scripts to process large (22 MByte) data base dumps,
I still use Perl.

> Transparent syntax?  Unfortunately for all of us, there is much more
> to a language than its syntax.  Take Lisp, for example.  No language
> has a simpler, more "transparent" syntax than Lisp.  Yet readability
> is (*cough*) not one of its strong points.

Which may be a valid criticism of Lisp, but has nothing to do with
Python. . .

> Not sure what "nicer" means; but the syntax of Python is nothing
> if not bizarre, at least from the POV of someone who is used to
> C/C++/Java/Pascal/Ada/Basic/Perl/Smalltalk/Eiffel/Lisp/....

Actually, in most cases, the above listed programmers will not
find Python syntax "bizarre".

Those who have been doing nothing but C for years, do in general
prefer Perl to Python, of course.

But even C++ programmers find Java's syntax a bit bizarre. . .
primarily because the langauges are *TOO* similiar!  (Lots
of little gotchas!)

> >There was a need for an interpreted scripting
> >language, which allowed the development of large scalable software -
> >Guido felt that Perl did not fit this bill, and I agree.
> 
> On what basis?  That you are predisposed to agree with Guido?

Based on the fact that Python was built from the ground up to be
an OO language: one that supported the development of large,
scalable software systems.

Look at the history of Perl. . . Perl was designed to fulfill a
different set of requirements (all these Perl users should know
what the P E R and L stand for, right? ;-).

> >Perl seems to be more of a rebellion against good language design,
> 
> Seems to you, maybe; but not to me, because "good language design"
> is subjective

No, it isn't.

> -- much more subjective than we have been brainwashed
> to believe by the C.S. establishment for 3 or 4 decades now.
> Take a little time to read Perl's creator's thoughts on why he
> designed Perl the way he did.  I for one can vouche that his approach
> has paid off big time in the real world.

And cost a lot, big time, in the real world also.  The most common
lament from a section manager: "I've got all this Perl code that
<fill-in-a-name> wrote, and nobody else can understand this stuff!"

Good language design is quite objective, and very measurable.

Training, support, maintenance costs. . . all of these can be
measured.

> What do you know about how much time it takes to debug Perl code?
> I spend 99% percent of my time writing and enhancing Perl code (and
> docs), and 1%, if that, fixing bugs in it.

I, too, have spent time on Perl code.  Ian's criticism is quite valid.

Perl's mantra makes Perl easier for the *INDIVIDUAL* to use (after
a suitable training period and apprenticeship).  It is a disaster,
though, for teams.

> However, I am not in a position to say how well this relates to
> Python.  I *can* say that it is enormously better than when I was
> programming in C and C++.

Agreed.  But this is more due to "scripting language" vs. "system
programming" language, than to anything specific about Perl.

The same productivity gains can be achieved by using other scripting
languages that have equivalent capabilities.

> What, Taint By Assocation?  The type indicators are very helpful,
> even though they tend to add a little bit of "noise" to the code.
> You get used to them quickly.

They are, in fact, quite necesary.  Note, however, that the
type prefix characters are a hindrance to doing clean, simple
OO.

Re: market numbers.  Since the number of computer related jobs is
increasing as a whole, almost every product that is even minimally
useful is seeing an absolute increase in users/customers.

As for Perl market *SHARE*. . . where did you get your numbers,
and what market do you think Perl have a share of?  This is not
a prelude to the standard-usenet-market-share attack, I'm just
curious, and will not comment further on any reply you make. . .

John S.


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

Date: Fri, 13 Aug 1999 13:00:22 -0600
From: "John W. Stevens" <jstevens@basho.fc.hp.com>
Subject: Re: Why use Perl when we've got Python?!
Message-Id: <37B46B46.80D5B51E@basho.fc.hp.com>

I R A Darth Aggie wrote:
> 
> On 12 Aug 1999 09:09:20 -0700, Tom Christiansen <tchrist@mox.perl.com>, in
> <37b2e3a0@cs.colorado.edu> wrote:
> 
> + The reason, of course, is because the leading white space changed the
> + syntax!  I cannot believe that the distaste you hold for using in Perl
> + dollars to specify variables or differently using [] to access an array
> + but {} to access a hash can possibly compare with the abhorrence that
> + fills a Perl programmer when he realizes that the number of spaces
> + at the front of the line is *syntactically significant*.
> 
> IIIIIIIIIIEEEEEEEEE! Is python related in some sick, twisted and demented
> way to either f77 or punch cards?

No.  Python enforces indentation to aid the programmer.

Fortran enforced spacing/indentation to aid the compiler.

> my head now hertz. I guess I knew that,
> but seeing it in black & white...

What, you don't indent you code?

Do you write C like:

long doi(int c,long d){int i;printf("This is valid
C!\n");d=c+d;for(i=c;i<d;i--)printf("%d", i);return d;} 

Or do you write it thusly:

long
doi(
   int    c,
   long   d)
{
   auto   int  i;

   printf("This is valid C!\n");

   d = c + d;
   for (i = c; i < d; i--)
      printf("%d", i);

   return d;
}

I had thought the arguments re: indentation and use of white space had
been settled years
ago. . .

John S.


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

Date: 13 Aug 1999 18:10:35 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Win32::Process
Message-Id: <7p1n2r$svr$1@lublin.zrz.tu-berlin.de>

Mike  <kangas@anlon.com> wrote in comp.lang.perl.misc:
>how do i get a parent process to grab variable values from a child
>process or have the child give the variable values to the parent.

Read the perl manual about open and take a close look at the "-|"
filehandle.

Anno


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

Date: Fri, 13 Aug 1999 18:18:11 GMT
From: zchon@my-deja.com
Subject: Writing lines to file twice or more (newbie question)
Message-Id: <7p1nga$8u2$1@nnrp1.deja.com>

  I am working on a text formatting program where
I read from I one text file, stick the large
string into an array and then format it.  Then I
stick the formated array back into a large string
and write the string to another text file.  The
problem is that when I finish running the program
and look at the text file it has written the
first line twice, the second line twice, third
line twice, forth line three times and so on
without a pattern I can see.  The file I am
reading the data from does have some blank lines
in between the data (ex:

data

data

data

data


data

  Any help would be greatly apperciated (This is
my first really perl program, no way like
learning how to swim then by being thrown in the
deep end) Thanks in advance

                   Sean


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 1 Jul 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.  

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" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. 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" from
almanac@ruby.oce.orst.edu. 

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


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