[33056] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4332 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Dec 20 09:09:15 2014

Date: Sat, 20 Dec 2014 06:09:03 -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           Sat, 20 Dec 2014     Volume: 11 Number: 4332

Today's topics:
    Re: Both substitute and filter <mvdwege@gmail.com>
    Re: Both substitute and filter <gamo@telecable.es>
    Re: Both substitute and filter <rweikusat@mobileactivedefense.com>
    Re: Both substitute and filter <rweikusat@mobileactivedefense.com>
    Re: Both substitute and filter <rweikusat@mobileactivedefense.com>
    Re: Both substitute and filter <stevem_@nogood.com>
    Re: Both substitute and filter (Seymour J.)
    Re: Both substitute and filter <rweikusat@mobileactivedefense.com>
        what is the perl expression to skip characters <91eed282a561b153be6ebcb2238f5a4e_6731@example.com>
    Re: what is the perl expression to skip characters <jurgenex@hotmail.com>
    Re: what is the perl expression to skip characters <news@lawshouse.org>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 18 Dec 2014 09:45:28 +0100
From: Mart van de Wege <mvdwege@gmail.com>
Subject: Re: Both substitute and filter
Message-Id: <86ioh9tkgn.fsf@gaheris.avalon.lan>

Georg Bauhaus <bauhaus@futureapps.invalid> writes:

>
>> As above, in
>>
>> my $xyz = 0;
>   there might be a few lines of code here!
>> ++$xys;
>>
>> the = 0 is useless.
>
> “= 0” tells us the kind of the scalar! That's quite a use, I'd say.
> $xyz is an int, it's not a string, and not a ref.

And all that might have been more clearly communicated by picking a more
obvious variable name, instead of adding a superfluous assignment.

Conciseness is a virtue in helping understanding too.

-- 
"We will need a longer wall when the revolution comes."
    --- AJS, quoting an uncertain source.


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

Date: Thu, 18 Dec 2014 10:21:39 +0100
From: gamo <gamo@telecable.es>
Subject: Re: Both substitute and filter
Message-Id: <m6u6b1$bpt$1@speranza.aioe.org>

El 18/12/14 a las 09:45, Mart van de Wege escribió:
> Georg Bauhaus <bauhaus@futureapps.invalid> writes:
>
>>
>>> As above, in
>>>
>>> my $xyz = 0;
>>    there might be a few lines of code here!
>>> ++$xys;
>>>
>>> the = 0 is useless.
>>
>> “= 0” tells us the kind of the scalar! That's quite a use, I'd say.
>> $xyz is an int, it's not a string, and not a ref.
>
> And all that might have been more clearly communicated by picking a more
> obvious variable name, instead of adding a superfluous assignment.
>
> Conciseness is a virtue in helping understanding too.
>

Oh, yes, the very own common sense. Here are some things I have as
a mania:

$c, $count, $kount -> counters

$i, $j, $k  -> subindexes

$ok, $flag  -> flags

$x, $y, $z -> coordinates or more subindexes

$r -> or is a rate or is a result

etc.


-- 
http://www.telecable.es/personales/gamo/
The generation of random numbers is too important to be left to chance


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

Date: Thu, 18 Dec 2014 14:54:34 +0000
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: Both substitute and filter
Message-Id: <87oar1uhxx.fsf@doppelsaurus.mobileactivedefense.com>

"Peter J. Holzer" <hjp-usenet3@hjp.at> writes:
> On 2014-12-17 14:30, Shmuel Metz <spamtrap@library.lspace.org.invalid> wrote:
>> In <yD8kw.352459$W25.293766@fx02.iad>, on 12/16/2014
>>    at 09:36 PM, Steve May <stevem_@nogood.com> said:
>>
>>>Not specific to the use of  my @array = (); 
>>
>> And not even relevant to it. The use of extraneous initialization is
>> not remotely similar to the use of meaningful variable names.
>>
>>>The point being that (for me) I find it easier
>>
>> Others have already said that they find it harder to read code that
>> has extraneous initialization.
>
> And others have said that they find it MORE readable.
>
> Can we please stop this childish "Do - don't - do - don't" game?

This started out as a simple remark, namely, that the assignment in

my @result = ();

was pointless because it doesn't have any effect. Using a simple example
from some other domain, assuming the solution to

(a + b) ** 2

is not presented as

a**2 + 2*a*b + b**2

but as

1 * (-17 + a**4/a**2 + (38 * a * b) / 19 + 1 / b**-2 + 17) / 1

[this term is probably wrong but a correct one could be constructed in a
similar way]

a term paper containing this won't end up in a gallery in order
demonstrate that - even in mathematics - individual, creative, stylistic
preferences are valued higher than substance but it will earn the person
who came up with this elaborate deception an energetic strike-through
and possibly, some educating remarks about wasting other people's time
with pointless nonsense.

And the situation is no different for code where 'terms' also have
exactly defined meanings.


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

Date: Thu, 18 Dec 2014 15:21:01 +0000
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: Both substitute and filter
Message-Id: <87k31pugpu.fsf@doppelsaurus.mobileactivedefense.com>

Steve May <stevem_@nogood.com> writes:
> On 12/17/2014 01:19 PM, Rainer Weikusat wrote:
>> Steve May <stevem_@nogood.com> writes:
>>> On 12/17/2014 07:32 AM, Rainer Weikusat wrote:

[...]

>>>> my @leaky_bucked = ();
>>>>
>>>> the assignment is obviously useless to anyone who understands the code
>>>> and a gratuitious burden to understanding ("Finally figured it out!
>>>> It's useless!") to everybody else. Because of this, it shouldn't exist
>>>> to begin with.

[...]

> Perhaps one reason the assignment doesn't bother me as much is the
> amount of work I do in javascript. I look at a very similar form every
> day (var myList = [];) and since I've been fiddling with javascript
> since the old Netscape LiveScript days.....

I've only written a bit of Javascript but quite a lot more Java where
the situation is similar:

int[] integers;

doesn't declare an array of integers but a reference to an array of
integers, hence, it needs an initialization of the form

int[] integers = {0, 1, 2};

or

int[] integers = new int[15];

(it's, of course, also similar to something like

static char *message = "Read all about it!";

in C).

But Perl is neither Java nor Javascript nor C and

my @array;

doesn't declare an uninitialized reference to an array (as in Java) or
an type-less name which can be associated with any kind of
value and has to be associated with some value but an array object with
certain, known properties. The Perl equivalent to the Javascript
statement would be

my $toaster = [];

which declares a scalar named $toaster and assigns a reference to an
anonymous array to it.

[...]

>> 1. Assuming a somewhat large project multiple people work on in a
>>     free-style way, each of these people will have his very own set of
>>     functionless code annotations he always uses because of historical
>>     reasons only known to him. Since everybody also reuses code written
>>     by everybody else without ever changing more than what is absolutely
>>     necessary, this quickly needs to a situation where half of the code
>>     or more (I'm not making this up) is a wild mix of different kinds of
>>     things which don't do anything useful and whose theoretical purpose
>>     nobody understands.

> Absolutely true, but in my experience serious large collaborative
> projects typically have (and enforce) style guides for all
> contributors.

This may be true in the weird open source universe where people write
'style guides' in order to make a resounding statement about text
editors they like or don't like (eg, Linux) but it certainly isn't true
for proprietary software where meaningless relics of some person's past
get copied and pasted around without spending a first, let alone a
second, thought on that until they finally blow up somewhere (actual
example) or until the ratio of useless to useful code is 4:1 (if this
is an exaggeration, it's not much of it --- I've experienced things
shrinking by 75% after removing everything which was obviously useless)
and - since the people whose excrements cover the whole place left long
ago - nobody really understands which parts of the code do something and
which parts don't. And this all starts with one guy writing three lines
of code, one of them because a problem has to be solved and the other
two because they encode a bit of his personal history.


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

Date: Thu, 18 Dec 2014 15:24:31 +0000
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: Both substitute and filter
Message-Id: <87fvcdugk0.fsf@doppelsaurus.mobileactivedefense.com>

"C.DeRykus" <derykus@gmail.com> writes:
> On Wednesday, December 17, 2014 4:01:12 PM UTC-8, Steve May wrote:
>> > In article <glkkw.927705$FX2.175120@fx18.iad>, stevem_@nogood.com says...

[...]

>> > Exactly.  I can't believe people are still arguing about this.  The code is pefectly clear
>> > either way so if the coder prefers it, then its fine.  And there is no computer for which the
>> > execution time difference would be significant or even measurable.
>> 
>> I don't know. Assuming I've not totally messed up (very possible) with 
>> the little script below, it looks like there is a performance hit. Not 
>> enough to worry about unless in a tight loop with many iterations, but...
>> 
>> ...  benchmark skipped 
>
> Mea culpa but I'm beating the dead horse only to mention an interesting
> fact about the whip. You will definitely see a performance hit because
> perl has to do more work:

[Perl 'assembly code' of both version]

I purposely didn't mention this because it usually matters a lot less
than the time other people have to waste digging through the haystack in
order to find the needle and because I already know the proud answer to
the issue in case it should also become a technical problem: "Arguably,
even the machine got hurt. Therefore, I've changed the compiler such
that useless code of the kind I like to write is deleted
automatically!".


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

Date: Thu, 18 Dec 2014 21:52:53 -0800
From: Steve May <stevem_@nogood.com>
Subject: Re: Both substitute and filter
Message-Id: <X2Pkw.936877$Fo3.307720@fx09.iad>

On 12/18/2014 07:21 AM, Rainer Weikusat wrote:
> Steve May <stevem_@nogood.com> writes:
>> On 12/17/2014 01:19 PM, Rainer Weikusat wrote:
>>> Steve May <stevem_@nogood.com> writes:
>>>> On 12/17/2014 07:32 AM, Rainer Weikusat wrote:
>
> [...]
>
>>>>> my @leaky_bucked = ();
>>>>>
>>>>> the assignment is obviously useless to anyone who understands the code
>>>>> and a gratuitious burden to understanding ("Finally figured it out!
>>>>> It's useless!") to everybody else. Because of this, it shouldn't exist
>>>>> to begin with.
>
> [...]
>
>> Perhaps one reason the assignment doesn't bother me as much is the
>> amount of work I do in javascript. I look at a very similar form every
>> day (var myList = [];) and since I've been fiddling with javascript
>> since the old Netscape LiveScript days.....
>
> I've only written a bit of Javascript but quite a lot more Java where
> the situation is similar:
>
> int[] integers;
>
> doesn't declare an array of integers but a reference to an array of
> integers, hence, it needs an initialization of the form
>
> int[] integers = {0, 1, 2};
>
> or
>
> int[] integers = new int[15];
>
> (it's, of course, also similar to something like
>
> static char *message = "Read all about it!";
>
> in C).
>
> But Perl is neither Java nor Javascript nor C and
>
> my @array;
>
> doesn't declare an uninitialized reference to an array (as in Java) or
> an type-less name which can be associated with any kind of
> value and has to be associated with some value but an array object with
> certain, known properties. The Perl equivalent to the Javascript
> statement would be
>
> my $toaster = [];
>
> which declares a scalar named $toaster and assigns a reference to an
> anonymous array to it.
>

Which, strangely enough, I do quite often. I'll skip my reasoning :-)


> [...]
>
>>> 1. Assuming a somewhat large project multiple people work on in a
>>>      free-style way, each of these people will have his very own set of
>>>      functionless code annotations he always uses because of historical
>>>      reasons only known to him. Since everybody also reuses code written
>>>      by everybody else without ever changing more than what is absolutely
>>>      necessary, this quickly needs to a situation where half of the code
>>>      or more (I'm not making this up) is a wild mix of different kinds of
>>>      things which don't do anything useful and whose theoretical purpose
>>>      nobody understands.
>
>> Absolutely true, but in my experience serious large collaborative
>> projects typically have (and enforce) style guides for all
>> contributors.
>
> This may be true in the weird open source universe where people write
> 'style guides' in order to make a resounding statement about text
> editors they like or don't like (eg, Linux) but it certainly isn't true
> for proprietary software where meaningless relics of some person's past
> get copied and pasted around without spending a first, let alone a
> second, thought on that until they finally blow up somewhere (actual
> example) or until the ratio of useless to useful code is 4:1 (if this
> is an exaggeration, it's not much of it --- I've experienced things
> shrinking by 75% after removing everything which was obviously useless)
> and - since the people whose excrements cover the whole place left long
> ago - nobody really understands which parts of the code do something and
> which parts don't. And this all starts with one guy writing three lines
> of code, one of them because a problem has to be solved and the other
> two because they encode a bit of his personal history.
>

Different experiences, for sure. Although I mostly work alone, a large 
percentage of the collaborative work I _have_ done has been using 
organization or project specific style guides.

Note that the project with the most anal retentive guide imaginable was 
proprietary. :-) I still have a copy of it around here somewhere and if 
I remember right it was over 40 pages. Those folks had a plan though. 
Their thinking was that an absolutely consistent coding style would make 
it much easier for any team member, past present or future, to read the 
code. They were right about that. Writing it? Not so much. :-)

Anyway, this subject has been thrashed beyond death.....

Thanks for causing me to re-examine my thinking.  Probably won't change 
much of what I do, but it's good to step back for a wider view once and 
a while.

Steve



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

Date: Thu, 18 Dec 2014 13:34:44 -0500
From: Shmuel (Seymour J.) Metz <spamtrap@library.lspace.org.invalid>
Subject: Re: Both substitute and filter
Message-Id: <54931e44$6$fuzhry+tra$mr2ice@news.patriot.net>

In <87k31pugpu.fsf@doppelsaurus.mobileactivedefense.com>, on
12/18/2014
   at 03:21 PM, Rainer Weikusat <rweikusat@mobileactivedefense.com>
said:

>Steve May <stevem_@nogood.com> writes:

>> Absolutely true, but in my experience serious large collaborative
>> projects typically have (and enforce) style guides for all
>> contributors.

>This may be true in the weird open source universe where people
>write 'style guides' in order to make a resounding statement about
>text editors they like or don't like (eg, Linux) but it certainly
>isn't true for proprietary software where meaningless relics of 
>some person's past get copied and pasted around without spending 
>a first, let alone a second, thought on that until they finally 
>blow up somewhere (actual example) or until the ratio of useless 
>to useful code is 4:1 (if this is an exaggeration, it's not much 
>of it --- I've experienced things shrinking by 75% after removing 
>everything which was obviously useless) and - since the people 
>whose excrements cover the whole place left long ago - nobody 
>really understands which parts of the code do something and which 
>parts don't. And this all starts with one guy writing three lines 
>of code, one of them because a problem has to be solved and the 
>other two because they encode a bit of his personal history.

I take it that you've never worked anywhere that had code and design
reviews? Or on a project that had a toolkit built around a specific
editor, formatting this in accordance with the project style? For
proprietary software it's easier to enforce local conventions than it
is on open source projects.

-- 
Shmuel (Seymour J.) Metz, SysProg and JOAT  <http://patriot.net/~shmuel>

Unsolicited bulk E-mail subject to legal action.  I reserve the
right to publicly post or ridicule any abusive E-mail.  Reply to
domain Patriot dot net user shmuel+news to contact me.  Do not
reply to spamtrap@library.lspace.org



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

Date: Fri, 19 Dec 2014 21:59:13 +0000
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: Both substitute and filter
Message-Id: <87bnmzz4ge.fsf@doppelsaurus.mobileactivedefense.com>

Steve May <stevem_@nogood.com> writes:
> On 12/18/2014 07:21 AM, Rainer Weikusat wrote:
>> Steve May <stevem_@nogood.com> writes:

[...]

>>> Perhaps one reason the assignment doesn't bother me as much is the
>>> amount of work I do in javascript. I look at a very similar form every
>>> day (var myList = [];) and since I've been fiddling with javascript
>>> since the old Netscape LiveScript days.....
>>
>> I've only written a bit of Javascript but quite a lot more Java where
>> the situation is similar:
>>
>> int[] integers;
>>
>> doesn't declare an array of integers but a reference to an array of
>> integers, hence, it needs an initialization of the form
>>
>> int[] integers = {0, 1, 2};
>>
>> or
>>
>> int[] integers = new int[15];
>>
>> (it's, of course, also similar to something like
>>
>> static char *message = "Read all about it!";
>>
>> in C).
>>
>> But Perl is neither Java nor Javascript nor C and
>>
>> my @array;
>>
>> doesn't declare an uninitialized reference to an array (as in Java) or
>> an type-less name which can be associated with any kind of
>> value and has to be associated with some value but an array object with
>> certain, known properties.

[...]

> Probably won't change much of what I do, but it's good to step back
> for a wider view once and a while.

You're - of course - free to remain shackled to the realm of lesser
languages for as long it you believe it suits you :-)


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

Date: Fri, 19 Dec 2014 21:22:00 +0000
From: simpleguy1 <91eed282a561b153be6ebcb2238f5a4e_6731@example.com>
Subject: what is the perl expression to skip characters
Message-Id: <61e5$549496f8$41b57997$18106@news.flashnewsgroups.com>

I need some help, please.

Here is the line to use and an example:

Received: from sender ([200.100.50.300])

Question: what is the Perl expression to skip characters  " : from sender
([ " 

Thank you!

-- 




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

Date: Fri, 19 Dec 2014 13:41:10 -0800
From: Jrgen Exner <jurgenex@hotmail.com>
Subject: Re: what is the perl expression to skip characters
Message-Id: <uq699aho1lpt1ac0lnqietgufs0566c8bn@4ax.com>

simpleguy1 <91eed282a561b153be6ebcb2238f5a4e_6731@example.com> wrote:
>I need some help, please.
>
>Here is the line to use and an example:
>
>Received: from sender ([200.100.50.300])
>
>Question: what is the Perl expression to skip characters  " : from sender
>([ " 

What do you mean by "skip characters"?

jue


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

Date: Fri, 19 Dec 2014 22:44:04 +0000
From: Henry Law <news@lawshouse.org>
Subject: Re: what is the perl expression to skip characters
Message-Id: <iNSdnTms_52kNwnJnZ2dnUVZ8mSdnZ2d@giganews.com>

On 19/12/14 21:22, simpleguy1 wrote:
> Received: from sender ([200.100.50.300])
>
> Question: what is the Perl expression to skip characters  " : from sender
> ([ "

Strong smell of homework here!

As well as learning to use Perl you should learn to ask good questions. 
  "Skip characters" could mean lots of things ... move past them in a 
list? Remove them from a string?

But I think you probably mean "How do I remove all the characters except 
the ones that look like an IP address (though you don't say anything 
about the trailing bracket and brace).

In that case try the regex \d+\.\d+\.\d+\.\d+ in a match statement and 
extract the matched text.

-- 

Henry Law            Manchester, England


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

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:

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

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#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 V11 Issue 4332
***************************************


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