Glenn Linderman wrote:
On approximately 4/19/2006 5:42 PM, came the following characters from
the keyboard of Sisyphus:
- Original Message -
From: Glenn Linderman
.
.
I think that the
for( grep ($_ != 3, @a))
is quite clear in bundling the element selection together, and
At 12:44 AM 4/20/2006, Chris Wagner wrote:
At 10:42 AM 4/20/2006 +1000, Sisyphus wrote:
On the subject of replacing brackets with modifiers (which I think was also
raised earlier on), I was surprised to find that using a modifier is about
25% faster than brackets:
'modifier' = 'for(@x) {$z1++ if
Glenn Linderman wrote:
The whole session is there in my message... I don't know how either, it
was my first use of Benchmark, I cloned it from Rob changed his 1
(which produced a warning) to 10 (which didn't). And added a couple new
cases.
Clearly you got different results from more
@listserv.ActiveState.comSubject:
Re: Iffor
snip good advice
Read Damian Conway's Perl Best Practices.
And when you feel the need to write clever code, read it
again./snip
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
Bill Ng [bill.ng AT citigroup.com] wrote:
Thanks,
Just ordered it from Amazon. Went the super-cheap route and ordered
it free shipping ... should have it in a week or so.
If anyone cares, I ended up using this as my code ... it accomplished
exactly what I was looking for:
@folders will have, at most 7 objects in it. All strings of less than
80 bytes.
Bill Ng
-Original Message-
From: Arms, Mike [mailto:[EMAIL PROTECTED]
Sent: Wednesday, April 19, 2006 5:24 PM
To: perl-win32-users@listserv.ActiveState.com
Cc: Ng, Bill
Subject: RE: Iffor
Bill, as long
- Original Message -
From: Glenn Linderman
.
.
I think that the
for( grep ($_ != 3, @a))
is quite clear in bundling the element selection together, and
separating it from the functions being performed.
I would much rather see (as suggested earlier on in this thread):
for(@a) {
- Original Message -
From: Glenn Linderman
.
.
Get a load of this variation:
perl
use warnings;
no warnings once;
use Benchmark;
@x = (1 .. 100);
@y = (1 .. 100);
@z = (1 .. 100);
@w = (1 .. 100);
$z1 = 0;
$z2 = 0;
$z3 = 0;
$z4 = 0;
timethese(10, {
At 10:42 AM 4/20/2006 +1000, Sisyphus wrote:
On the subject of replacing brackets with modifiers (which I think was also
raised earlier on), I was surprised to find that using a modifier is about
25% faster than brackets:
'modifier' = 'for(@x) {$z1++ if $_ != 3}',
'brackets' = 'for(@y) {if($_ !=
Bill Ng [bill.ng AT citigroup.com] wrote:
Syntax issue (I think),
I'm trying to do the following:
I need to execute a block of instructions for all items in an array
except for one.
So if my array was:
@a=(1,2,3,4,5);
And we assume that I don't want to execute the block if the value of
How about this?
###
use strict;
use warnings;
my @a = (1,2,3,4,5);
foreach(@a){
unless($_ == 3){
#do something...
}
}
###
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Ng, Bill
Sent: Tuesday, April 18,
, 2006 2:28 PM
To: 'Ng, Bill'; perl-win32-users@listserv.ActiveState.com
Subject: RE: Iffor
How about this?
###
use strict;
use warnings;
my @a = (1,2,3,4,5);
foreach(@a){
unless($_ == 3){
#do something...
}
}
###
-Original Message-
From
of an issue, just looking to tidy up the code. Thanks again.
Bill
-Original Message-
From: Timothy Johnson [mailto:[EMAIL PROTECTED]
Sent: Tuesday, April 18, 2006 5:41 PM
To: Ng, Bill; perl-win32-users@listserv.ActiveState.com
Subject: RE: Iffor
Okay, I'm a moron. I somehow missed that last
@a = (1,2,3,4,5);
for $x (@a)
{
if($x==3){next;}
print $x\n;
}
##
You wrote:
Syntax issue (I think),
I'm trying to do the following:
I need to execute a block of instructions for all items in an array
except for one.
So if my array was:
@a=(1,2,3,4,5);
And we
Ng, Bill asked on April 18, 2006 12:59 PM
So if my array was:
@a=(1,2,3,4,5);
And we assume that I don't want to execute the block if the
value of $_ is 3 ...
Then, in my head, I'm looking for the WORKING (key word there)
version of this:
---
@a =
Read the last sentence of my email ... =)
Bill Ng
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Jerry Kassebaum
Sent: Tuesday, April 18, 2006 6:07 PM
To: perl-win32-users@listserv.ActiveState.com
Subject: RE: Iffor
@a = (1,2,3,4,5);
for $x
Ng, Bill wrote:
Performance isn't really what I'm going for, just simpler code.
For the past 4 years, I've been coding to get the job done, no
matter how many lines it takes or how ugly it is to read, as
long as it works that's fine. But recently you guys have shown
Ng, Bill wrote:
Performance isn't really what I'm going for, just simpler code.
If clear code is what you want, you won't get it using a 'next' as some
have suggested. A 'next' syntactically looks like any other line, and
is therefore not easily noticed as part of the control flow.
[Soap box warning...]
You seem to be suffering from a common
perl programming psychosis: the sometimes unbearable urge to write clever
perl in the fewest possible number of lines ... that infects us all from
time to time...
Read Damian Conway's Perl Best Practices.
And when you feel the need to
19 matches
Mail list logo