[28614] in Perl-Users-Digest
Perl-Users Digest, Issue: 9978 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Nov 18 03:05:58 2006
Date: Sat, 18 Nov 2006 00:05:08 -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, 18 Nov 2006 Volume: 10 Number: 9978
Today's topics:
Re: [OT] Salmon <uri@stemsystems.com>
Decompiler <gilbert3b2g@msn.com>
Re: Do I *have* to use 'OOP' to use modules? <merrile@telus.net>
Re: help CGI in perl and C <john@castleamber.com>
Re: help CGI in perl and C <tadmc@augustmail.com>
HoA bug? Size limit? <hpbenton@scripps.edu>
Re: HoA bug? Size limit? <see.sig@rochester.rr.com>
Re: HoA bug? Size limit? <uri@stemsystems.com>
Re: HoA bug? Size limit? <someone@example.com>
Re: HoA bug? Size limit? <someone@example.com>
Re: HoA bug? Size limit? <uri@stemsystems.com>
Re: How can I create instantiable objects (not classes) (reading news)
Re: How to make Perl's regex engine "halt" after a matc <louisREMOVE@REMOVEh4h.com>
Re: How to make Perl's regex engine "halt" after a matc <tadmc@augustmail.com>
is there a bash script to perl converter? ToddAndMargo@gbis.com
Re: is there a bash script to perl converter? <tintin@invalid.invalid>
new CPAN modules on Sat Nov 18 2006 (Randal Schwartz)
Re: Newbie's easy question/answer - I hope <evillen@gmail.com>
Re: Newbie's easy question/answer - I hope <DJStunks@gmail.com>
Re: OT: O'Reilly 'Perl CD Bookshelf' - gone for good? (Randal L. Schwartz)
Re: OT: O'Reilly 'Perl CD Bookshelf' - gone for good? <john@castleamber.com>
Re: OT: O'Reilly 'Perl CD Bookshelf' - gone for good? <dha@panix.com>
p-value calculation <rahul.thathoo@gmail.com>
Re: what the difference between these loops? <john@castleamber.com>
Re: Win32::GUI or Tk ? <benmorrow@tiscali.co.uk>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 17 Nov 2006 19:58:49 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: [OT] Salmon
Message-Id: <x7wt5t1sfq.fsf@mail.sysarch.com>
>>>>> "JWK" == John W Krahn <someone@example.com> writes:
JWK> Uri Guttman wrote:
>>>>>>> "LSX" == Lawrence Statton XE2/N1GAK <yankeeinexile@gmail.com> writes:
>>
LSX> I write CGI in Perl, and my boss is coming to dinner. Do you have any
LSX> good salmon recipes that would show I know how to write good Perl
LSX> code? :)
>>
>> i write perl and love to cook salmon. i just bought about 1lb of wild
>> salmon today from a great local fishmonger for $14/lb.
JWK> Pacific or Atlantic salmon?
hard to find wild atlantic salmon in general so i suspect pacific. i
will ask the next time i see the perl^Wfish monger.
>> i will probably
>> broil or grill it with possibly an herbed butter for a topping. yum! i
>> should write a cpan module on this.
JWK> The grocer I go to sells it pre-prepared marinated in herbs and
JWK> lemon, I usually bake it. Mmmmmmm, salmon!
you are paying a big premium for that. i almost never buy premarinated
fish as it is too easy to do it yourself. tonight i have some sea
scallops from that monger (local from new england) marinating in olive
oil and crushed garlic (fresh of course!). in a few minutes i will broil
them to perfection!
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: 17 Nov 2006 20:10:12 -0800
From: "jim" <gilbert3b2g@msn.com>
Subject: Decompiler
Message-Id: <1163823012.182218.117090@m73g2000cwd.googlegroups.com>
Is there such thing as a decompiler that I can use in my window
enviroment
------------------------------
Date: Fri, 17 Nov 2006 23:27:55 GMT
From: Merrilee Larson <merrile@telus.net>
Subject: Re: Do I *have* to use 'OOP' to use modules?
Message-Id: <%zr7h.115$rB6.19@clgrps13>
On 2006-11-17, Uri Guttman <uri@stemsystems.com> wrote:
>>>>>> "ML" == Merrilee Larson <merrile@telus.net> writes:
>
> ML> Do you mean to say that C programmers are *less* productive, as a rule,
> ML> than C++ programmers?
>
> it all depends on the coder as usual.
>
> >> I think you would probably be OK. You mention web-sites being a primary
> >> focus, The CGI module has both an OO and a procedural interface.
>
> ML> Good to know! Is that typical of most modules, or only a selected few? Is
> ML> there a (slick) way of determining this?
>
> slick? rtfm is about as slick as you can get. and if you don't like OO
> (which makes little sense as perl OO is very simple to write for the
> caller), then you can write simple procedural wrappers around the OO
> modules you want. there is even a module (i have to look for it) that
> can actually mess with exporting procedural subs that share a singleton
> object.
>
> but you need to explain why you hate OO it is just another way of
> organizing code and it has many advantages (but is no silver bullet).
>
OO simply doesn't *feel* natural to me. I'm 100% more comfortable with a
procedural language. My first exposure to programming was with Perl4. I found
easy and intuitive. Afterwards, I had some Java code pushed unto me, and *that*
did me in for OOP. I feel the same way about PHP - although I prefer Perl to
PHP.
BTW, I'm *not* disparaging Perl OOP. I'm simply expressing how I feel about it.
In my other life, I fluently speak 3 languages: English, French and Spanish.
Learning Italian would probably not be all that much of a challenge. However,
I don't think that I would find learning Chinese/Korean/Japanese all that easy.
No offense meant to any of you Asian Perl hackers. As well, my not *groking*
Chinese et al, does not mean that these are not fine, expressive languages in
their own right. Of course they are - but they might be beyond most of us
"honkies" ;) later....
--
duke
------------------------------
Date: 18 Nov 2006 00:07:08 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: help CGI in perl and C
Message-Id: <Xns987EB85082196castleamber@130.133.1.4>
Lawrence Statton XE2/N1GAK <yankeeinexile@gmail.com> wrote:
> John Bokma <john@castleamber.com> writes:
>> gmclee@21cn.com wrote:
>>
>> [ C (!) code ]
>>
>> > However, when I run the program. The server returns
>> >
>> > 'xxx\cgi-bin\test.cgi' script produced no output
>>
>> Does it when called from the command line? Also, the C related group
>> is that way --->
>>
>> Even though there are Perl programmers that can help you, if they do
>> so, where is the end? Your next question might be how to cook salmon.
>>
>
> I write CGI in Perl, and my boss is coming to dinner. Do you have any
> good salmon recipes that would show I know how to write good Perl
> code? :)
use strict and use warnings for starters?
Or maybe tell that you looked at CPAN for recipes.
--
John Experienced Perl programmer: http://castleamber.com/
Perl help, tutorials, and examples: http://johnbokma.com/perl/
------------------------------
Date: Fri, 17 Nov 2006 20:13:28 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: help CGI in perl and C
Message-Id: <slrnelsr28.q4g.tadmc@tadmc30.august.net>
John Bokma <john@castleamber.com> wrote:
> gmclee@21cn.com wrote:
>
> [ C (!) code ]
>
>> However, when I run the program. The server returns
>>
>> 'xxx\cgi-bin\test.cgi' script produced no output
>
> Does it when called from the command line? Also, the C related group is
> that way --->
>
> Even though there are Perl programmers that can help you, if they do so,
> where is the end? Your next question might be how to cook salmon.
Should you pronounce the "ell" in salmon, or is it silent?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 17 Nov 2006 17:20:27 -0800
From: "PB0711" <hpbenton@scripps.edu>
Subject: HoA bug? Size limit?
Message-Id: <1163812827.071357.305980@f16g2000cwb.googlegroups.com>
Hello all,
I have just finished a script with 3 for loops, at the end of which it
generates an HoA. I've printed out that it goes throught all expected
8000 loops but there are only a unique 1599 keys. However, if I print
the keys out before I put them into the HoA I can see that it does all
combinations that I expect. Is this a bug or a size limit on the number
of keys for an HoA??
Thanks,
Paul
-------------OUTPUT------------
1599 <- keys
total 8000
-------------CODE-------------
my @AoA = (
["Ala", "Alanine", "71.08", "3", "2", "1","7", "0"],
["Arg", "Arginine", "156.19", "6", "2", "4", "14", "0"],
["His", "Histidine", "137.14","6","2","3","9", "0"],
["Phe", "Phenylalanine", "147.18", "9", "2", "1", "11", "0"],
["Cys", "Cysteine", "103.14", "3", "2", "1", "7", "1"],
["Gly", "Glycine", "57.05", "2", "2", "1", "5", "0"],
["Gln", "Glutamine", "128.13", "5", "3", "2", "10", "0"],
["Glu", "Glutamate", "129.11", "5", "4", "1", "9", "0"],
["Asp", "Asparte", "115.09", "4", "4", "1", "7", "0"],
["Lys", "Lysine", "128.17", "6", "2", "2", "14", "0"],
["Leu", "Leucine", "113.16", "6", "2", "1", "13", "0"],
["Met", "Methionine", "131.20", "5", "2","1","11", "1"],
["Asn", "Asparagine", "114.10", "4", "3", "2","8", "0"],
["Ser", "Serine", "87.08", "3", "3", "1", "7", "0"],
["Tyr", "Tryosine", "163.17", "9", "3", "1","11", "0"],
["Thr", "Threonine", "101.10", "4", "3", "1", "9", "0"],
["Ile", "Isoleucine", "113.16", "6","2","1","13","0"],
["Trp", "Trytophan","186.21","11","2","2","12", "0"],
["Pro", "Proline", "97.12", "5", "2", "1","9", "0"],
["Val", "Valine", "99.13", "5", "2", "1", "11", "0"],
);
#----------------------------------
#making dipeptides - a nasty way V2 will do a sub
for (my $i=0; $i < $#AoA+1; $i++){
for (my $j=0; $j < $#AoA+1; $j++){
for (my $n=0; $n < $#AoA+1; $n++) {
$total++;
my $formula=0;
my $c=($AoA[$i][3]+$AoA[$j][3])+$AoA[$n][3];
my $o=($AoA[$i][4]+$AoA[$j][4])+$AoA[$n][4];
my $h=($AoA[$i][6]+$AoA[$j][6])+$AoA[$n][6];
my $n=($AoA[$i][5]+$AoA[$j][5])+$AoA[$n][5];
my $s=($AoA[$i][7]+$AoA[$j][7])+$AoA[$n][7];
if ($s == 0){
$formula = "C$c" . "H$h" . "N$n" . "O$o";
} else {
$formula = "C$c" . "H$h" . "N$n" . "O$o" . "S$s";
}
my $mass = ($AoA[$i][2] + $AoA[$j][2]) + $AoA[$n][2];
my $name = "$AoA[$i][0] $AoA[$j][0] $AoA[$n][0]";
$HoA{$name} = [ "$mass", "$formula"];
print "$name\n";
}
}
}
#for my $comp (keys %HoA) {
# print "$comp: @{$HoA{$comp}}\n";
#}
my ($count, $added);
my @key = keys %HoA;
print "$#key <- keys\n";
#----------------------------------
print "total $total\n";
------------------------------
Date: Sat, 18 Nov 2006 02:53:41 GMT
From: Bob Walton <see.sig@rochester.rr.com>
Subject: Re: HoA bug? Size limit?
Message-Id: <VAu7h.26842$xw1.23655@twister.nyroc.rr.com>
PB0711 wrote:
...
> I have just finished a script with 3 for loops, at the end of which it
> generates an HoA. I've printed out that it goes throught all expected
> 8000 loops but there are only a unique 1599 keys. However, if I print
> the keys out before I put them into the HoA I can see that it does all
> combinations that I expect. Is this a bug or a size limit on the number
> of keys for an HoA??
Yes, it is a bug -- in your program, not Perl. Perl will handle many
millions of hash keys in a hash with no problem. The problem is that
some of your keys appear once, some four times, and some 14 times. 'Phe
Asp Cys', for example, shows up 4 times; 'Met Trp Cys' shows up 14
times; 'Arg Ala Lys' shows up once. I found that out by adding the
statement:
$cnt{$name}++;
after your $HoA statement, then at the end adding
use Data::Dumper;
print Dumper(\%cnt);
to print it out.
As to why that happens, you clobbered your for loop index variable $n
with the statement
my $n=($AoA[$i][5]+$AoA[$j][5])+$AoA[$n][5];
In the next "my $s=" statement you probably want the index variable, and
in the if statement you probably want the new $n. Code like the
following seems to fare better (I just used $k instead of $n for the
third for loop index).
Also, your "keys" output line is off by one -- you printed the index
number of the last element of @key rather than the number of elements in
@key.
And, you didn't
use strict;
since there were undeclared variables when it was added. Let Perl help
you all it can.
And BTW, thanks for making an example anyone could copy/paste/run.
...
> Paul
> -------------OUTPUT------------
...
8000 <- keys
total 8000
> -------------CODE-------------
use warnings;
use strict;
my @AoA = (
["Ala", "Alanine", "71.08", "3", "2", "1","7", "0"],
["Arg", "Arginine", "156.19", "6", "2", "4", "14", "0"],
["His", "Histidine", "137.14","6","2","3","9", "0"],
["Phe", "Phenylalanine", "147.18", "9", "2", "1", "11", "0"],
["Cys", "Cysteine", "103.14", "3", "2", "1", "7", "1"],
["Gly", "Glycine", "57.05", "2", "2", "1", "5", "0"],
["Gln", "Glutamine", "128.13", "5", "3", "2", "10", "0"],
["Glu", "Glutamate", "129.11", "5", "4", "1", "9", "0"],
["Asp", "Asparte", "115.09", "4", "4", "1", "7", "0"],
["Lys", "Lysine", "128.17", "6", "2", "2", "14", "0"],
["Leu", "Leucine", "113.16", "6", "2", "1", "13", "0"],
["Met", "Methionine", "131.20", "5", "2","1","11", "1"],
["Asn", "Asparagine", "114.10", "4", "3", "2","8", "0"],
["Ser", "Serine", "87.08", "3", "3", "1", "7", "0"],
["Tyr", "Tryosine", "163.17", "9", "3", "1","11", "0"],
["Thr", "Threonine", "101.10", "4", "3", "1", "9", "0"],
["Ile", "Isoleucine", "113.16", "6","2","1","13","0"],
["Trp", "Trytophan","186.21","11","2","2","12", "0"],
["Pro", "Proline", "97.12", "5", "2", "1","9", "0"],
["Val", "Valine", "99.13", "5", "2", "1", "11", "0"],
);
#----------------------------------
#making dipeptides - a nasty way V2 will do a sub
my(%HoA,%cnt,$total);
for (my $i=0; $i < $#AoA+1; $i++){
for (my $j=0; $j < $#AoA+1; $j++){
for (my $k=0; $k < $#AoA+1; $k++) {
$total++;
my $formula=0;
my $c=($AoA[$i][3]+$AoA[$j][3])+$AoA[$k][3];
my $o=($AoA[$i][4]+$AoA[$j][4])+$AoA[$k][4];
my $h=($AoA[$i][6]+$AoA[$j][6])+$AoA[$k][6];
my $n=($AoA[$i][5]+$AoA[$j][5])+$AoA[$k][5];
my $s=($AoA[$i][7]+$AoA[$j][7])+$AoA[$k][7];
if ($s == 0){
$formula = "C$c" . "H$h" . "N$n" . "O$o";
} else {
$formula = "C$c" . "H$h" . "N$n" . "O$o" . "S$s";
}
my $mass = ($AoA[$i][2] + $AoA[$j][2]) + $AoA[$k][2];
my $name = "$AoA[$i][0] $AoA[$j][0] $AoA[$k][0]";
$HoA{$name} = [ "$mass", "$formula"];
$cnt{$name}++;
print "$name\n";
}
}
}
#for my $comp (keys %HoA) {
# print "$comp: @{$HoA{$comp}}\n";
#}
my ($count, $added);
print scalar(keys(%HoA))." <- keys\n";
#----------------------------------
print "total $total\n";
use Data::Dumper;
#print Dumper(\%cnt);
__END__
HTH.
--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl
------------------------------
Date: Sat, 18 Nov 2006 00:21:59 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: HoA bug? Size limit?
Message-Id: <x7psblz5vs.fsf@mail.sysarch.com>
>>>>> "P" == PB0711 <hpbenton@scripps.edu> writes:
someone else figured out the bugs so i will do a little code
review. this can be cleaned up in many ways and that would lead to fewer
bugs here and in your future code.
P> my @AoA = (
i know this is an example but hopefully that is not a real variable
name. call it something to do with amino acids or whatever.
P> ["Ala", "Alanine", "71.08", "3", "2", "1","7", "0"],
[ qw( Ala Alanine 71.08 3 2 17 0 ) ],
a little bit easier to read.
P> #making dipeptides - a nasty way V2 will do a sub
P> for (my $i=0; $i < $#AoA+1; $i++){
P> for (my $j=0; $j < $#AoA+1; $j++){
P> for (my $n=0; $n < $#AoA+1; $n++) {
gack! i hate seeing useless and bug prone c style for loops.
foreach my $i ( 0 .. $#AoA ){
foreach my $j ( 0 .. $#AoA ){
foreach my $k ( 0 .. $#AoA ){
and k usually follows n.
P> $total++;
P> my $formula=0;
P> my $c=($AoA[$i][3]+$AoA[$j][3])+$AoA[$n][3];
P> my $o=($AoA[$i][4]+$AoA[$j][4])+$AoA[$n][4];
P> my $h=($AoA[$i][6]+$AoA[$j][6])+$AoA[$n][6];
P> my $n=($AoA[$i][5]+$AoA[$j][5])+$AoA[$n][5];
P> my $s=($AoA[$i][7]+$AoA[$j][7])+$AoA[$n][7];
why is there a paren around the first + ?
there is a massive amount of redundancy in there. it hard to read and
see what are the slight differences in each line.
first off, you can grab $AoA[$i] (and j and k) as soon as you have the
index value. this makes it cleaner and faster as you lose all those
extra array lookups.
and use whitespace. it was created for you to use.
foreach my $i ( 0 .. $#AoA ){
my $AoA_i = $AoA[$i] ;
foreach my $j ( 0 .. $#AoA ){
my $AoA_j = $AoA[$j] ;
foreach my $k ( 0 .. $#AoA ){
my $AoA_k = $AoA[$k] ;
my $s = $AoA_i->[7] + $AoA_j->[7] + $AoA_k->[7] ;
now we also have the repeated execution of that expression with 3 .. 7
so we factor that out with a map:
my( $c, $o, $h, $n, $s ) = map {
$AoA_i->[$_] + $AoA_j->[$_] + $AoA_k->[$_] }
} 3 .. 7 ;
but even that bothers me. you don't USE $i except to index into AoA. so
why even have the index variables? we can then eliminate the indexing to
get each loop's reference.
this now reduced the loop to:
foreach my $AoA_i ( @AoA ){
foreach my $AoA_j ( @AoA ){
foreach my $AoA_k ( @AoA ){
my( $c, $o, $h, $n, $s ) = map {
$AoA_i->[$_] + $AoA_j->[$_] + $AoA_k->[$_] }
} 3 .. 7 ;
P> if ($s == 0){
P> $formula = "C$c" . "H$h" . "N$n" . "O$o";
P> } else {
P> $formula = "C$c" . "H$h" . "N$n" . "O$o" . "S$s";
P> }
use ?: for conditional assignments. use "" for interpolation of the
whole string. you just need {} around the variable names. and you can
declare $formula here at the same time.
my $formula = ($s == 0) ?
"C${c}H${h}N${n}O${o}" :
"C${c}H${h}N${n}O${o}S${s}" ;
but there is more redundancy there as both versions start the same. so
we factor out one more time.
my $formula = "C${c}H${h}N${n}O${o}" .
($s == 0) ? '' : "S${s}" ;
P> my $mass = ($AoA[$i][2] + $AoA[$j][2]) + $AoA[$n][2];
add that to the above map as it is the same expression.
P> my $name = "$AoA[$i][0] $AoA[$j][0] $AoA[$n][0]";
my $name = "$AoA_i->[0] $AoA_j->[0] $AoA_k->[0]";
P> $HoA{$name} = [ "$mass", "$formula"];
don't quote scalar vars for no reason. see the FAQ for why.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Sat, 18 Nov 2006 06:02:15 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: HoA bug? Size limit?
Message-Id: <Hlx7h.11841$gy2.3099@edtnps90>
Uri Guttman wrote:
>>>>>>"P" == PB0711 <hpbenton@scripps.edu> writes:
>
> gack! i hate seeing useless and bug prone c style for loops.
>
> foreach my $i ( 0 .. $#AoA ){
> foreach my $j ( 0 .. $#AoA ){
> foreach my $k ( 0 .. $#AoA ){
>
> and k usually follows n.
I though that k usually follows j?
> P> $total++;
> P> my $formula=0;
> P> my $c=($AoA[$i][3]+$AoA[$j][3])+$AoA[$n][3];
> P> my $o=($AoA[$i][4]+$AoA[$j][4])+$AoA[$n][4];
^ ^ ^
> P> my $h=($AoA[$i][6]+$AoA[$j][6])+$AoA[$n][6];
^ ^ ^
> P> my $n=($AoA[$i][5]+$AoA[$j][5])+$AoA[$n][5];
^ ^ ^
> P> my $s=($AoA[$i][7]+$AoA[$j][7])+$AoA[$n][7];
^ ^ ^
>
> why is there a paren around the first + ?
>
> there is a massive amount of redundancy in there. it hard to read and
> see what are the slight differences in each line.
>
> first off, you can grab $AoA[$i] (and j and k) as soon as you have the
> index value. this makes it cleaner and faster as you lose all those
> extra array lookups.
>
> and use whitespace. it was created for you to use.
>
> foreach my $i ( 0 .. $#AoA ){
>
> my $AoA_i = $AoA[$i] ;
> foreach my $j ( 0 .. $#AoA ){
>
> my $AoA_j = $AoA[$j] ;
> foreach my $k ( 0 .. $#AoA ){
>
> my $AoA_k = $AoA[$k] ;
>
> my $s = $AoA_i->[7] + $AoA_j->[7] + $AoA_k->[7] ;
>
>
> now we also have the repeated execution of that expression with 3 .. 7
> so we factor that out with a map:
>
> my( $c, $o, $h, $n, $s ) = map {
The correct order should be:
my( $c, $o, $n, $h, $s ) = map {
> $AoA_i->[$_] + $AoA_j->[$_] + $AoA_k->[$_] }
> } 3 .. 7 ;
John
--
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order. -- Larry Wall
------------------------------
Date: Sat, 18 Nov 2006 06:05:30 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: HoA bug? Size limit?
Message-Id: <Kox7h.11842$gy2.956@edtnps90>
John W. Krahn wrote:
> Uri Guttman wrote:
>>
>>now we also have the repeated execution of that expression with 3 .. 7
>>so we factor that out with a map:
>>
>> my( $c, $o, $h, $n, $s ) = map {
>
> The correct order should be:
>
> my( $c, $o, $n, $h, $s ) = map {
>
>
>> $AoA_i->[$_] + $AoA_j->[$_] + $AoA_k->[$_] }
>> } 3 .. 7 ;
Also, you've got one too many } in there.
John
--
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order. -- Larry Wall
------------------------------
Date: Sat, 18 Nov 2006 02:10:16 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: HoA bug? Size limit?
Message-Id: <x764ddz0vb.fsf@mail.sysarch.com>
>>>>> "JWK" == John W Krahn <someone@example.com> writes:
JWK> Uri Guttman wrote:
>>>>>>> "P" == PB0711 <hpbenton@scripps.edu> writes:
>>
>> gack! i hate seeing useless and bug prone c style for loops.
>>
>> foreach my $i ( 0 .. $#AoA ){
>> foreach my $j ( 0 .. $#AoA ){
>> foreach my $k ( 0 .. $#AoA ){
>>
>> and k usually follows n.
JWK> I though that k usually follows j?
not in MY alphabet!
P> my $h=($AoA[$i][6]+$AoA[$j][6])+$AoA[$n][6];
JWK> ^ ^ ^
why are you pointing out the integers there?
JWK> The correct order should be:
JWK> my( $c, $o, $n, $h, $s ) = map {
my comments and code were highly untested. they were more for
ejimicating the OP than actually writing working code. :)
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Sat, 18 Nov 2006 03:32:55 GMT
From: "Mumia W. (reading news)" <paduille.4060.mumia.w@earthlink.net>
Subject: Re: How can I create instantiable objects (not classes)?
Message-Id: <H9v7h.222$tM1.106@newsread1.news.pas.earthlink.net>
On 11/17/2006 11:51 AM, Julien wrote:
> Mumia W. (reading news) wrote:
>> It sounds like what you're trying to do is "delegation." Delegation
>> occurs when the programmer decides to let one object send those messages
>> that it can't understand to another object. For example, an object of
>> type Car might receive a message named "ticket," and since a car does
>
> Hi Mumian,
>
> Thanks a lot for replying :)
>
> I think maybe I didn't make myself clear enough, but anyway I am not
> sure that delegation as you are describing is what I am trying to do.
> To follow your car example, I am trying to instantiate 100 identical
> (say red, with AC, auto windows or whatever) Toyota Corollas, but in a
> simulation, each instance of the corolla may have a different speed,
> driver, location, etc. So my object defines what the Corolla looks
> like off of the assembly line,
No, a class will define what a Corolla looks like off of the assembly
line, and each "instance" of a Corolla is an "object."
> but an object-instance has additional
> attributes with state information. I could just add a "speed"
> attribute to the Corolla object and instantiate it 100x, but it seems
> to me a waste of memory because a subset of the Corolla attributes are
> shared and indentical across all the instances of the Corolla class.
>
This would be class data.
> Another way to put my question is, how to share the values of a subset
> of attributes of a given class across all instances of that class?
>
> Julien
>
perldoc perltooc
perldoc perltoot
--
paduille.4060.mumia.w@earthlink.net
------------------------------
Date: Fri, 17 Nov 2006 18:00:47 -0800
From: "Wayne M. Poe" <louisREMOVE@REMOVEh4h.com>
Subject: Re: How to make Perl's regex engine "halt" after a match
Message-Id: <4s77qqFu1tb4U1@mid.individual.net>
Jim Gibson wrote:
> In article <4s6arsFu8n52U1@mid.individual.net>, Wayne M. Poe
> <louisREMOVE@REMOVEh4h.com> wrote:
>
> > [This is a reply to a thread from earlier this year
> > Reply generated from source post with full headers
> > from groups.google.com]
> >
> > robic0 wrote:
> > > On 18 Feb 2006 07:48:30 -0800, "Dominic van der Zypen"
> > > <dominic.zypen@gmail.com> wrote:
> > >
>
> [OP snipped]
>
> > >
> > > This is trivial. Why would you need this?
> > > I would consider this a waste of my time to even read such a
> > > proposition.
> > > If you can't post a real world problem/question then don't post
> > > here...
> >
> > I was reading this on google groups archives and I just had to reply
> > to it. I understand I'm a few months late, but being in the hospital
> > at that time fighting cancer I hope is a good enough reason.
> >
> > I'm actually surprised no one responded to this post at the time it
> > was originally posted.
> >
> > Since when can one not post a simplified version of the problem to
> > make it easier to trouble shoot? Isn't that what you are SUPPOSED to
> > do? Rather than posting a longer code snippet where one would have
> > to sift through the code to find the real problem?
> >
> > Or maybe that's just me.
>
> robic0 is a known troll. Many or most of the regulars here simply
> ignore his posts, for good reason.
So noted.
------------------------------
Date: Fri, 17 Nov 2006 18:02:53 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: How to make Perl's regex engine "halt" after a match
Message-Id: <slrnelsjdd.pjl.tadmc@tadmc30.august.net>
Wayne M. Poe <louisREMOVE@REMOVEh4h.com> wrote:
> [This is a reply to a thread from earlier this year
> Reply generated from source post with full headers
> from groups.google.com]
>
> robic0 wrote:
> I was reading this on google groups archives and I just had to reply to
> it.
Please do not feed the troll.
> I'm actually surprised no one responded to this post at the time it was
> originally posted.
Because not feeding a troll is how you make them go elsewhere.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 17 Nov 2006 20:48:59 -0800
From: ToddAndMargo@gbis.com
Subject: is there a bash script to perl converter?
Message-Id: <1163825339.671311.207020@m73g2000cwd.googlegroups.com>
Hi All,
Is there a such thing as a bash script to perl converter?
Many thanks,
-T
------------------------------
Date: Sat, 18 Nov 2006 18:04:13 +1300
From: "Tintin" <tintin@invalid.invalid>
Subject: Re: is there a bash script to perl converter?
Message-Id: <455e868d$0$21137$88260bb3@free.teranews.com>
<ToddAndMargo@gbis.com> wrote in message
news:1163825339.671311.207020@m73g2000cwd.googlegroups.com...
> Hi All,
>
> Is there a such thing as a bash script to perl converter?
Yes. It's called a programmer.
--
Posted via a free Usenet account from http://www.teranews.com
------------------------------
Date: Sat, 18 Nov 2006 05:42:10 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Sat Nov 18 2006
Message-Id: <J8wvuA.1wr4@zorch.sf-bay.org>
The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN). You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.
Algorithm-C3-0.06
http://search.cpan.org/~blblack/Algorithm-C3-0.06/
A module for merging hierarchies using the C3 algorithm
----
Alzabo-0.8904
http://search.cpan.org/~drolsky/Alzabo-0.8904/
A data modelling tool and RDBMS-OO mapper
----
Apache-Session-Memorycached-2.1.0
http://search.cpan.org/~egerman/Apache-Session-Memorycached-2.1.0/
An implementation of Apache::Session
----
Astro-VO-VOEvent-0.9.3
http://search.cpan.org/~aallan/Astro-VO-VOEvent-0.9.3/
----
Astro-VO-VOEvent-0.9.4
http://search.cpan.org/~aallan/Astro-VO-VOEvent-0.9.4/
Object interface to parse and create VOEvent messages
----
Bundle-BioPerl-2.1.7
http://search.cpan.org/~craffi/Bundle-BioPerl-2.1.7/
A bundle to install external CPAN modules used by BioPerl 1.5.2
----
Crypt-Rijndael-0.06_05
http://search.cpan.org/~bdfoy/Crypt-Rijndael-0.06_05/
Crypt::CBC compliant Rijndael encryption module
----
Crypt-Rijndael-0.06_06
http://search.cpan.org/~bdfoy/Crypt-Rijndael-0.06_06/
Crypt::CBC compliant Rijndael encryption module
----
HTML2XHTML-0.03.03
http://search.cpan.org/~oembry/HTML2XHTML-0.03.03/
Wrapper to command-line program that converts from HTML 3.x/4.x to XHTML 1.0
----
HTTP-Async-0.05
http://search.cpan.org/~evdb/HTTP-Async-0.05/
process multiple HTTP requests in parallel without blocking.
----
Lexical-Persistence-0.96
http://search.cpan.org/~rcaputo/Lexical-Persistence-0.96/
Persistent lexical variable values for arbitrary calls.
----
Logger-Syslog-1.0
http://search.cpan.org/~sukria/Logger-Syslog-1.0/
an simple wrapper over Syslog for Perl
----
MIME-Types-1.18
http://search.cpan.org/~markov/MIME-Types-1.18/
Definition of MIME types
----
Mozilla-Mechanize-GUITester-0.05
http://search.cpan.org/~bosu/Mozilla-Mechanize-GUITester-0.05/
enhances Mozilla::Mechanize with GUI testing.
----
Net-GPSD-Server-Fake-0.02
http://search.cpan.org/~mrdvt/Net-GPSD-Server-Fake-0.02/
Provides a Fake GPSD test harness.
----
Net-MAC-Vendor-1.16
http://search.cpan.org/~bdfoy/Net-MAC-Vendor-1.16/
look up the vendor for a MAC
----
Pod-MultiLang-0.11
http://search.cpan.org/~hio/Pod-MultiLang-0.11/
multi languages in Pod
----
Prima-1.21
http://search.cpan.org/~karasik/Prima-1.21/
a perl graphic toolkit
----
SVN-Notify-Config-0.0907
http://search.cpan.org/~jpeacock/SVN-Notify-Config-0.0907/
Config-driven Subversion notification
----
Statistics-SDT-0.01
http://search.cpan.org/~rgarton/Statistics-SDT-0.01/
Signal detection theory measures of sensitivity and response-bias
----
String-Diff-0.01
http://search.cpan.org/~yappo/String-Diff-0.01/
Simple diff to String
----
Sub-ForceEval-1.30
http://search.cpan.org/~lembark/Sub-ForceEval-1.30/
eval subroutines, re-throw exceptions if there is an eval; otherwise cluck and return undef.
----
Sub-ForceEval-1.31
http://search.cpan.org/~lembark/Sub-ForceEval-1.31/
eval subroutines, re-throw exceptions if there is an eval; otherwise cluck and return undef.
----
WebService-Geograph-API-0.2
http://search.cpan.org/~sden/WebService-Geograph-API-0.2/
Perl interface to the Geograph.co.uk API
----
WebService-MusicBrainz-0.05
http://search.cpan.org/~bfaist/WebService-MusicBrainz-0.05/
----
XML-Document-RTML-1.15
http://search.cpan.org/~aallan/XML-Document-RTML-1.15/
module which builds and parses RTML documents
----
XML-Document-RTML-1.16
http://search.cpan.org/~aallan/XML-Document-RTML-1.16/
module which builds and parses RTML documents
----
XML-Document-Transport-0.2
http://search.cpan.org/~aallan/XML-Document-Transport-0.2/
----
Yahoo-Marketing-0.07
http://search.cpan.org/~jlavallee/Yahoo-Marketing-0.07/
an interface for Yahoo! Search Marketing's Web Services.
----
bioperl-1.5.2_004-RC
http://search.cpan.org/~sendu/bioperl-1.5.2_004-RC/
----
bioperl-1.5.2_004-RCb
http://search.cpan.org/~sendu/bioperl-1.5.2_004-RCb/
----
bioperl-1.5.2_RC4
http://search.cpan.org/~sendu/bioperl-1.5.2_RC4/
If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.
This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
http://www.stonehenge.com/merlyn/LinuxMag/col82.html
print "Just another Perl hacker," # the original
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: 17 Nov 2006 17:21:31 -0800
From: "evillen@gmail.com" <evillen@gmail.com>
Subject: Re: Newbie's easy question/answer - I hope
Message-Id: <1163812891.560568.309150@f16g2000cwb.googlegroups.com>
That's terse - thanks ,-)
John Bokma wrote:
> David Squire <David.Squire@no.spam.from.here.au> wrote:
>
> > print "Match for $_\n" if /^0$|^8$|^14$|^23$/;
>
> That's a lot of noise, how about:
>
> print "Match for $_\n" if /^(0|8|14|23)$/
>
> --
> John Experienced Perl programmer: http://castleamber.com/
>
> Perl help, tutorials, and examples: http://johnbokma.com/perl/
------------------------------
Date: 17 Nov 2006 18:36:32 -0800
From: "DJ Stunks" <DJStunks@gmail.com>
Subject: Re: Newbie's easy question/answer - I hope
Message-Id: <1163817392.147667.266350@j44g2000cwa.googlegroups.com>
David Squire wrote:
> given that you seem really to be testing for numerical equality
> here, the version below is probably clearer, and quite possibly faster:
>
> ----
>
> #!/usr/bin/perl
>
> use strict;
> use warnings;
>
> my @good_numbers = (0, 8, 14, 23);
> for my $i (0..32) {
> $_ == $i and print "Match for $i\n" and last for @good_numbers;
> }
>
> ----
arrays are not suited for existence tests. to truly speedup, use a
hash.
my %good_numbers = map { $_ => 1 } (0, 8, 14, 23);
for my $i ( 0..32 ) {
print "Match for $i\n" if $good_numbers{$i};
}
-jp
------------------------------
Date: 17 Nov 2006 21:09:31 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: OT: O'Reilly 'Perl CD Bookshelf' - gone for good?
Message-Id: <86r6w1qr1w.fsf@blue.stonehenge.com>
>>>>> "Robert" == Robert Hicks <sigzero@gmail.com> writes:
Robert> Yes...but we were hoping for "future" editions.
yeah, and thanks to pirates, you won't be getting them.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
--
Posted via a free Usenet account from http://www.teranews.com
------------------------------
Date: 18 Nov 2006 06:13:04 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: OT: O'Reilly 'Perl CD Bookshelf' - gone for good?
Message-Id: <Xns987F23732840castleamber@130.133.1.4>
merlyn@stonehenge.com (Randal L. Schwartz) wrote:
>>>>>> "Robert" == Robert Hicks <sigzero@gmail.com> writes:
>
> Robert> Yes...but we were hoping for "future" editions.
>
> yeah, and thanks to pirates, you won't be getting them.
Get over it Randal. Reply to my post which made a lot more sense then this
O'Reilly propaganda you are parroting.
--
John Experienced Perl programmer: http://castleamber.com/
Perl help, tutorials, and examples: http://johnbokma.com/perl/
------------------------------
Date: Sat, 18 Nov 2006 07:24:57 +0000 (UTC)
From: "David H. Adler" <dha@panix.com>
Subject: Re: OT: O'Reilly 'Perl CD Bookshelf' - gone for good?
Message-Id: <slrneltda9.ge8.dha@panix2.panix.com>
On 2006-11-18, John Bokma <john@castleamber.com> wrote:
> merlyn@stonehenge.com (Randal L. Schwartz) wrote:
>
>>>>>>> "Robert" == Robert Hicks <sigzero@gmail.com> writes:
>>
>> Robert> Yes...but we were hoping for "future" editions.
>>
>> yeah, and thanks to pirates, you won't be getting them.
>
> Get over it Randal. Reply to my post which made a lot more sense then this
> O'Reilly propaganda you are parroting.
Ok, I'm confused as to how saying that a practices that encourages
people not to buy books discourages publishers from continuing to
publish new versions of that book doesn't make sense. Or, for that
matter, is propaganda. Publishers put books out because they make money
on it and if they're less likely to make money on a particular book,
they're less likely to continue publishing that book. In what way is
this nonsensical?
I mean, if you want to argue that pirating is, in reality, a minor drain
on revenues, I'd still be likely to disagree with you, but at least we'd
have something we could try to quantify. Dismissing the general idea,
however, makes no sense to me.
dha
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
M-x induce-carpal-tunnel-syndrome
- Greg Bacon
------------------------------
Date: 17 Nov 2006 23:27:21 -0800
From: "rahulthathoo" <rahul.thathoo@gmail.com>
Subject: p-value calculation
Message-Id: <1163834841.869778.114740@b28g2000cwb.googlegroups.com>
Hi.
I was wondering if anyone here would know how to go about calculating
the p-value in perl. The
thing is that I have 2 sets A and B. There are lets say 200 entries in
each set, each entry between 0 and 1 and I need to find the Pearson
Correlation Coefficient r. I did this in perl. I had r for 200 points.
Now I want to be able to calculate the p-value for this experiment. How
do i do that in PERL. I can do that easily in Excel using the TDist
function. So for a given r, I can calculate the t-value (called the
statistic) as t=3Dr/sqrt[(1-r=B2)/(N-2)] where r is the pearson and N =3D
200 and from here I can get the TDist in Excel which is the p-value.
But I cant seem to do this in PERL? Any clues?
Rahul
------------------------------
Date: 18 Nov 2006 00:04:00 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: what the difference between these loops?
Message-Id: <Xns987EB7C834EE6castleamber@130.133.1.4>
Uri Guttman <uri@stemsystems.com> wrote:
>>>>>> "JB" == John Bokma <john@castleamber.com> writes:
>
> JB> Depends on what you're doing. I have used composite keys in the
> JB> past, and I am sure others have done so.
>
> and that is supported in perl (even perl4!) as pseudo multilevel
> hashes. look for $; in perlvar for more.
>
> but to the OP, a multilevel hash is the way to go. merging keys can be a
> useful technique as john says but it isn't that common.
Recently used it: http://johnbokma.com/perl/google-search-cloud.html
$stats{ "$path:$status" }{ sum }++;
:
my ( $path, $status ) = $ps =~ /(.*):(\d+)/;
But yeah, I rarely use this.
> as for the OP's original issue, it seems he didn't rtfm properly about
> each and how it works and is reset.
:-D What else is new.
--
John Experienced Perl programmer: http://castleamber.com/
Perl help, tutorials, and examples: http://johnbokma.com/perl/
------------------------------
Date: Fri, 17 Nov 2006 16:04:31 +0000
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: Win32::GUI or Tk ?
Message-Id: <f53134-pma.ln1@osiris.mauzo.dyndns.org>
Quoth zentara <zentara@highstream.net>:
> On 16 Nov 2006 04:25:26 -0800, "MoshiachNow" <lev.weissman@creo.com>
> wrote:
>
> >What is more popular/preferable/recommended for GUI in Perl:
> >Win32::GUI or Tk ?
>
> Well Tk will also run on linux, unix, Mac; so Tk is more
> cross-platform.
>
> Don't forget the new kid on the block, Gtk2. I think
> Gtk2 is the future.
> It is actively developed.
> It's syntax is close to the c, so you can port to c easily.
For me this would be a disadvantage. I write Perl so I *don't* have to
make my code look like C.
> It is very state of the art, and allows you to take full control.
It also looks (IME) awful on windows, and I presume on MacOS as well.
In my (admittedly limited) experience, by far the easiest toolkit to use
is Tk. The Perl bindings are really good. However, I guess it's not
maintained any more (has anyone taken it on?) and it doesn't always
match the native widgets on Win32, either.
Ben
--
Like all men in Babylon I have been a proconsul; like all, a slave ... During
one lunar year, I have been declared invisible; I shrieked and was not heard,
I stole my bread and was not decapitated.
~ benmorrow@tiscali.co.uk ~ Jorge Luis Borges, 'The Babylon Lottery'
------------------------------
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 9978
***************************************