[25502] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7746 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Feb 6 18:10:22 2005

Date: Sun, 6 Feb 2005 15:10:13 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sun, 6 Feb 2005     Volume: 10 Number: 7746

Today's topics:
    Re: perl style: can I combine two steps into one? <postmaster@castleamber.com>
    Re: perl style: can I combine two steps into one? <postmaster@castleamber.com>
    Re: perl style: can I combine two steps into one? (Anno Siegel)
    Re: perl style: can I combine two steps into one? <postmaster@castleamber.com>
    Re: perl style: can I combine two steps into one? <postmaster@castleamber.com>
    Re: perl style: can I combine two steps into one? (Anno Siegel)
    Re: perl style: can I combine two steps into one? <postmaster@castleamber.com>
    Re: Perl Versus Python <dtrudgett@holdthespam_yahoo.com>
    Re: Perl Versus Python <spamtrap@dot-app.org>
    Re: Perl Versus Python (Anno Siegel)
    Re: Perl Versus Python <spamtrap@dot-app.org>
        Question about building perl 5.8.6 multi-threaded on Li <tommydkat@gmail.com>
    Re: Thanks for reply to Perl core dump issue .. i have  (Anno Siegel)
    Re: Why aren't 'warnings' on by default? <postmaster@castleamber.com>
    Re: Why aren't 'warnings' on by default? <hendrik_maryns@despammed.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 6 Feb 2005 19:34:50 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: perl style: can I combine two steps into one?
Message-Id: <Xns95F58A24A13CCcastleamber@130.133.1.4>

RedGrittyBrick wrote:

> John Bokma wrote:

[ snip ]

> Since I was raised on FORTRAN, it is deeply ingrained in me that one 
> should never test floating point numbers for equality. So I tend to feel 
> more comfortable writing "x >= 10" than "x = 10" where x is being 
> incremented in some fashion.

It wasn't a float.

> Unfortunately this aversion also applies 
> inappropriately to integer comparisons.
> 
> Perhaps one should write
>   last if i == 10;
>   die "Too many impossible things before breakfast." if i > 10;

As silly as:

die "Panic" if int( i ) != i;

if i is already int.

If i "suddenly" becomes float, it's quite weird to rely on the fact that 
you already took care of i possible becoming float.

-- 
John                   Small Perl scripts: http://johnbokma.com/perl/
               Perl programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html
                        


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

Date: 6 Feb 2005 19:47:36 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: perl style: can I combine two steps into one?
Message-Id: <Xns95F58C4EE9E86castleamber@130.133.1.4>

Anno Siegel wrote:

> John Bokma  <postmaster@castleamber.com> wrote in comp.lang.perl.misc:
>> Anno Siegel wrote:
>> 
>> > John Bokma  <postmaster@castleamber.com> wrote in
>> > comp.lang.perl.misc: 
>> >> Anno Siegel wrote:
> 
>> > It is more frequently used, but for no good reason.  Pre-increment
>> > is the simpler process, not only implementationally.  There are two
>> > values involved in $x++, but only one in ++$x.
>> 
>> A programmer shouldn't be bothered by that in normal cases.
> 
> If "normal case" includes use of the return value of $x++, it can't
> be ignored.

It was clear I was talking of cases in which the increment is in void
context. 

It's obvious that

if ( $i++ ... )

is not the same as

if ( ++$i ... )

( or at least to me ).

Also, in (void context), I can't see why

++$i;

and 

$i++;

can not be optimised to be equal. And "Programming Perl" seems to
confirm that: 

" The optimizer will notice this and optimize the post-increment into
  a pre-increment, because that's a bit faster to execute. " (footnote,
  p26 of 3rd edition) 

Using constructions because they "feel faster" is odd.

-- 
John                   Small Perl scripts: http://johnbokma.com/perl/
               Perl programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html
                        


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

Date: 6 Feb 2005 20:17:48 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: perl style: can I combine two steps into one?
Message-Id: <cu5u1c$tc$1@mamenchi.zrz.TU-Berlin.DE>

John Bokma  <postmaster@castleamber.com> wrote in comp.lang.perl.misc:
> Anno Siegel wrote:
> > John Bokma  <postmaster@castleamber.com> wrote in comp.lang.perl.misc:

[should $x++ or ++$x be preferred?]

> It was clear I was talking of cases in which the increment is in void
> context. 

Are you saying different rules of preference should apply depending on
context?  I hope not.  But then all applications must be considered.

> Also, in (void context)...

[$i++ and ++$i are optimized to be the same]

> Using constructions because they "feel faster" is odd.

I never said anything about speed, I was careful not to.

"++ $x" is conceptually simpler than "$x ++", that's why it should be
preferred.  The specific action of "$x ++" is rarely needed in Perl
(though it can come in handy), because the indexing operations it applies
to are usually done by the interpreter.  It should be the exception,
not the rule.

Anno


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

Date: 6 Feb 2005 20:44:39 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: perl style: can I combine two steps into one?
Message-Id: <Xns95F595FC5460Acastleamber@130.133.1.4>

Anno Siegel wrote:

> John Bokma  <postmaster@castleamber.com> wrote in comp.lang.perl.misc:
>> Anno Siegel wrote:
>> > John Bokma  <postmaster@castleamber.com> wrote in 
comp.lang.perl.misc:
> 
> [should $x++ or ++$x be preferred?]
> 
>> It was clear I was talking of cases in which the increment is in void
>> context. 
> 
> Are you saying different rules of preference should apply depending on
> context?

Yup, I use a hammer when I need one. And when a tweezer is better, I use 
that. Sounds to me sound tool usage.

> I hope not.  But then all applications must be considered.
> 
>> Also, in (void context)...
> 
> [$i++ and ++$i are optimized to be the same]
> 
>> Using constructions because they "feel faster" is odd.
> 
> I never said anything about speed, I was careful not to.

"Pre-increment is the simpler process, not only implementationally.  
There are two values involved in $x++, but only one in ++$x. "

Since $x++ is in void context optimized to ++$x there is no difference. 
So just using ++$x because you try to think at low level is bad IMNSHO. 
Even more since in void context it doesn't matter at all.

> "++ $x" is conceptually simpler than "$x ++", that's why it should be
> preferred.

Programming Perl 3rd edition just told me that $x++ is optimized into
++$x in void context.

> The specific action of "$x ++" is rarely needed in Perl

$hash{ $x }++; ?

A quick find in files using Textpad in my Perl installation over all pm 
files gave:

1345 occurences of ++
A quick glance gave me the impression that ++$i is used more than $i++.

Also note that I prefer $i++ in void context. When the value of $i is 
directly used it depends on the *context*.

Sometimes:

if ( ++$i == 10 ) ...

is better (to me) compared to

if ( $i++ == 10 ) ...

I use what is best overall, not because of some idea.

-- 
John                   Small Perl scripts: http://johnbokma.com/perl/
               Perl programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html
                        


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

Date: 6 Feb 2005 20:47:04 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: perl style: can I combine two steps into one?
Message-Id: <Xns95F596658AAD1castleamber@130.133.1.4>

Abigail wrote:

> And the subroutine returns a floating point number which, due to
> rounding errors, isn't quite an integer.
> 
> That's why I prefer to use '$i >= 10' instead of '$i == 10'.

What if the subroutine returns "meh" ?

-- 
John                   Small Perl scripts: http://johnbokma.com/perl/
               Perl programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html
                        


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

Date: 6 Feb 2005 21:48:43 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: perl style: can I combine two steps into one?
Message-Id: <cu63br$3hg$2@mamenchi.zrz.TU-Berlin.DE>

John Bokma  <postmaster@castleamber.com> wrote in comp.lang.perl.misc:
> Anno Siegel wrote:
> > John Bokma  <postmaster@castleamber.com> wrote in comp.lang.perl.misc:
> >> Anno Siegel wrote:
> >> > John Bokma  <postmaster@castleamber.com> wrote in 
> comp.lang.perl.misc:
> > 
> > [should $x++ or ++$x be preferred?]

I have said what I wanted to say about this (more than that, I'm afraid).
This is getting repetitive, we're boring everyone else to tears.  Sorry...

Anno


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

Date: 6 Feb 2005 22:01:02 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: perl style: can I combine two steps into one?
Message-Id: <Xns95F5A2EF13506castleamber@130.133.1.4>

Anno Siegel wrote:

> John Bokma  <postmaster@castleamber.com> wrote in comp.lang.perl.misc:
>> Anno Siegel wrote:
>> > John Bokma  <postmaster@castleamber.com> wrote in
>> > comp.lang.perl.misc: 
>> >> Anno Siegel wrote:
>> >> > John Bokma  <postmaster@castleamber.com> wrote in 
>> comp.lang.perl.misc:
>> > 
>> > [should $x++ or ++$x be preferred?]
> 
> I have said what I wanted to say about this (more than that, I'm
> afraid). This is getting repetitive, we're boring everyone else to
> tears.  Sorry... 

I can't speak for everyone else.

And programming style is never boring to me :-D. I have given your style 
some serious thought, ie. if it doesn't matter to use either $i++ or ++$i 
to use ++$i. But since in my experience $i++ is more used in void context, 
I stick with the latter. Also since PP 3rd edition states that in void 
context it doesn't matter. 

-- 
John                   Small Perl scripts: http://johnbokma.com/perl/
               Perl programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html
                        


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

Date: Mon, 07 Feb 2005 07:16:46 +1100
From: David Trudgett <dtrudgett@holdthespam_yahoo.com>
Subject: Re: Perl Versus Python
Message-Id: <4_uNd.7137$i6.66084@nasal.pacific.net.au>

surfunbear@yahoo.com wrote:

>  I've read some posts on Perl versus Python and studied a bit of my
> Python book.
> 

Hey, you didn't even cross post to the Python newsgroup! How's a 
language war supposed to start like that?? :-)

David


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

Date: Sun, 06 Feb 2005 16:12:20 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Perl Versus Python
Message-Id: <aPadnbAhwO-rFZvfRVn-sA@adelphia.com>

surfunbear@yahoo.com wrote:

> 1. Perl seems to have alot of packaged utilities available through
> CPAN, the comprehensive perl network.

In my opinion, CPAN is Perl's major advantage. With CPAN, the question
becomes less about the code you write, and more about the code you *don't*
write.

> 2. Python is apparantly better at object oriented. Perl has some kind
> of name spacing, I have used that in a limited way. Does Perl use a
> cheap and less than optimal Object oriented approach ?

That's a matter of philosophy. Perl allows a clean OO approach - but it
doesn't require it. For my part, I do OO in Perl all the time, and I don't
have a problem with it.

I find it puzzling that some folks need a language that forcibly prevents
them from crossing object boundaries - why can't they simply refrain from
doing so on their own? If they can't, isn't that their own weakness, not
that of the language they're using?

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: 6 Feb 2005 21:40:53 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Perl Versus Python
Message-Id: <cu62t5$3hg$1@mamenchi.zrz.TU-Berlin.DE>

Sherm Pendley  <spamtrap@dot-app.org> wrote in comp.lang.perl.misc:
> surfunbear@yahoo.com wrote:

> That's a matter of philosophy. Perl allows a clean OO approach - but it
> doesn't require it. For my part, I do OO in Perl all the time, and I don't
> have a problem with it.

So do I -- as long as I deal with my own code.

> I find it puzzling that some folks need a language that forcibly prevents
> them from crossing object boundaries - why can't they simply refrain from
> doing so on their own?

They don't, that's the problem.  In particular, some authors of classes
published on CPAN don't.  Perl lets you drag stuff in and out of an object
willy-nilly, so that's what people do, making clean inheritance harder
than it has to be.  I for one would be glad about a way to enforce the
definition of accessors and their use throughout the rest of a class.

> If they can't, isn't that their own weakness, not
> that of the language they're using?

Well, yes, but the weakness becomes a weakness of available software.
It wouldn't be an entirely bad thing if OO newbies had something in
Perl to stiffen their backs.  In Perl, you must know how to do it the
OO way.  In Python, I understand, there is no other.

Anno


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

Date: Sun, 06 Feb 2005 17:17:25 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Perl Versus Python
Message-Id: <0fednbbKWrzrCpvfRVn-3A@adelphia.com>

Anno Siegel wrote:

> They don't, that's the problem.  In particular, some authors of classes
> published on CPAN don't.  Perl lets you drag stuff in and out of an object
> willy-nilly, so that's what people do, making clean inheritance harder
> than it has to be.  I for one would be glad about a way to enforce the
> definition of accessors and their use throughout the rest of a class.

I prefer the approach taken by Cocoa/Objective-C. Objective-C does offer
both "private" and "protected" modifiers, but they're trivially simple to
bypass with a type cast.

Few people actually do so, because there are a number of tangible benefits
to be gained by writing and using accessors that follow a simple design
pattern. The pattern is pervasive through all of Cocoa, and using it in
your own code makes a number of things Just Work - key-value coding
observing, serialization, Cocoa bindings, etc.

In short, if Perl's approach has a weakness, I don't think it's the lack of
a stick, but rather the lack of a tasty carrot.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: 6 Feb 2005 12:00:23 -0800
From: "Tom Williams" <tommydkat@gmail.com>
Subject: Question about building perl 5.8.6 multi-threaded on Linux
Message-Id: <1107720023.412448.187140@c13g2000cwb.googlegroups.com>

Greetings to you all.  :)

I'm trying to find out what my options are for getting a recent/current
perl release built multi-threaded on my Linux-based server, based on
RedHat 9 (I believe).  I'm running a 2.4.20 kernel and have glibc-2.3.2
installed.

When I've tried to build any perl release newer than 5.8.2, I've had
"make test" fail on the "wait" test, as described in my previous post:

http://groups-beta.google.com/group/comp.lang.perl.misc/browse_thread/thread/b6fdf5dafb19a24/68af887a91a64e2c?q=Tom+Williams&_done=%2Fgroup%2Fcomp.lang.perl.misc%2Fsearch%3Fgroup%3Dcomp.lang.perl.misc%26q%3DTom+Williams%26qt_g%3D1%26searchnow%3DSearch+this+group%26&_doneTitle=Back+to+Search&&d#68af887a91a64e2c

Is my problem with getting a post-5.8.2 multi-threaded perl build
successfully built due to a RedHat configured glibc, perhaps, or is
there possibly something else wrong that is causing me grief?

Would upgrading glibc (or at least rebuilding glibc-2.3.2) help?

Thanks in advance for any advice, tips, or information you might have.

Peace...

Tom



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

Date: 6 Feb 2005 19:46:27 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Thanks for reply to Perl core dump issue .. i have found a work around ...
Message-Id: <cu5s6j$t33$1@mamenchi.zrz.TU-Berlin.DE>

Gancy <ganesh_tiwari@hotmail.com> wrote in comp.lang.perl.misc:
> Hi,
> I really appreciate for time you people (Bob, Xhos, Anno, ...) took to
> reply to my posting.  Off late i posted a message asking a help for
> perl core dump issues for the following regex.
> 
> $np = qr{
> \(
> (?:
> (?>[^()]+ )
> |
> (??{ $np })
> )*
> \)
> }x;
> }
> 
> Though there were many possible solution to the problem, i have a
> workaround for time being.  I just had to increase the stack limit on
> my solaris box to allow recursing to go deeper.

Oh dear...

> I know this is not the
> brightest solution, but fine till i come up with something solid for
> production code.

Well, the regex above was never meant for production.  It's a demonstration
that it *can be done*, no more no less.

A water-tight solution would have to parse the code, much like a compiler
does.  A regex-only solution is not going to do.

Even an approximation would first have to recognize C (or C++) comments and
strings (and characters), as toke.c shows.  I think there are regex solutions
for each, but both must be done together, not one after the other:

    /* this " doesn't start a string */
    s = "this /* doesn't start a comment";

I don't think there's a regex that does both.

Unless you involve rather high-level tools, a production solution doesn't
seem to be around the corner.

Anno


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

Date: 6 Feb 2005 19:28:24 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: Why aren't 'warnings' on by default?
Message-Id: <Xns95F5890E57092castleamber@130.133.1.4>

Peter Wyzl wrote:

> "John Bokma" <postmaster@castleamber.com> wrote in message 
> news:Xns95F48FE711B99castleamber@130.133.1.4...
> : Peter Wyzl wrote:
> :
> : > "John Bokma" <postmaster@castleamber.com> wrote in message
> : > news:Xns95F3F20B3A2F9castleamber@130.133.1.4...
> : > : Chris Mattern wrote:
> 
> <snip>
> 
> : > First thing I do when looking at someone else's code is turn them
> : > both on, and look at the resultant errors/warnings.
> : >
> : > A recent example is a publicly available 'blogging' script that
> : > does use 'my' declarations, but inappropriately (ie, declares the
> : > same variable name three times in the same scope - 'declaraton
> : > masks earlier in same scope'). That gives some idea about the
> : > types of problems to be encountered elsewhere.  Gives you some
> : > idea of what the original programmer does or doesn't know.
> :
> : You aren't talking about GreyMatter are you ? (Yikes)
> 
> No. Bloxsom.  No doubt there are others as bad or worse.

Another program to avoid. GreyMatter, last time I looked at it, was 
badly written. The maker(s) had plans to port it to PHP... Aargh.

> Some of the concepts in these programs are 'non scalable' at best. 
> For example, reading in all the entries, formatting them and printing
> them out dynamically for every hit, instead of converting them to
> static pages and only updating for new entries.  The unnecessary
> server load for busy blogging servers is rather huge. :(

Yeah, can imagine. I have a small site/blog, and my access_log of last 
month was over 100 MB :-D.

-- 
John                   Small Perl scripts: http://johnbokma.com/perl/
               Perl programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html
                        


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

Date: Sun, 06 Feb 2005 23:56:45 +0100
From: Hendrik Maryns <hendrik_maryns@despammed.com>
Subject: Re: Why aren't 'warnings' on by default?
Message-Id: <xaydnaJhoYE2PZvfRVnyhg@scarlet.biz>

Abigail schreef:
<something very important>

<-- >
A perl rose:  perl -e '@}>-`-,-`-%-'

This doesn't do anything for me?

H.


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

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


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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

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

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


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


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