From rjbs-perl-abe at lists.manxome.org Fri Apr 8 12:39:24 2005 From: rjbs-perl-abe at lists.manxome.org (Ricardo SIGNES) Date: Fri Apr 8 12:39:46 2005 Subject: [ABE.pm] YAPC! Message-ID: <20050408193924.GC225@manxome.org> Well, I haven't heard from anybody out there, but I registered for YAPC last night! I had a good time, last year. I met sungo, learned a bunch of good stuff, made fun of Harry Potter III, and saw Phil eat lots of burger. http://rjbs.manxome.org/yapc/2004/ It's dirt cheap -- cheaper this year than last. $85 for registration as usual, but only about $80 / night lodging. That's $80 /CANADIAN/ dollars, so $65 American. I encourage everyone to think about going. It's a good time. -- rjbs -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available Url : http://mail.pm.org/pipermail/abe-pm/attachments/20050408/8014236e/attachment.bin From phil at five-lawrences.com Fri Apr 8 12:45:52 2005 From: phil at five-lawrences.com (Phil Lawrence) Date: Fri Apr 8 12:49:11 2005 Subject: [ABE.pm] YAPC! In-Reply-To: <20050408193924.GC225@manxome.org> References: <20050408193924.GC225@manxome.org> Message-ID: <4256DF70.8090807@five-lawrences.com> Ricardo SIGNES wrote: > Well, I haven't heard from anybody out there, but I registered for YAPC > last night! Well, I'm thinking about it. Guess I better think faster. I think Jim was *possibly* interested in going. Jim? Phil From rjbs-perl-abe at lists.manxome.org Sat Apr 9 15:37:38 2005 From: rjbs-perl-abe at lists.manxome.org (Ricardo SIGNES) Date: Sat Apr 9 15:37:48 2005 Subject: [ABE.pm] Practical Common Lisp Message-ID: <20050409223738.GE225@manxome.org> Hey, everybody! I've requested a review copy of a new book from Apress, "Practical Common Lisp." It's not about Perl, but the buzz on the Lisp blogs is that it's a good book, and I think anybody could benefit from learning Lisp. If you're interested in reading it, let me know and I'll make a little queue for passing it around! By the way, I'm halfway through Higher-Order Perl, and it's really very informative. If you like coding, you will probably like HOP. -- rjbs -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available Url : http://mail.pm.org/pipermail/abe-pm/attachments/20050409/a5a4f69d/attachment.bin From glim at mycybernet.net Sun Apr 10 09:10:00 2005 From: glim at mycybernet.net (Gerard Lim) Date: Sun Apr 10 09:29:20 2005 Subject: [ABE.pm] Reminder: Yet Another Perl Conference in Toronto, June 27 - 29 Message-ID: Yet Another YAPC::NA 2005 Conference Reminder --------------------------------------------- YAPC::NA 2005 is Yet Another Perl Conference, North America, this year to be held in downtown Toronto, Ontario, Canada, Mon - Wed 27 - 29 June 2005. Important Dates/Deadlines ------------------------- April 18 -- deadline for paper submissions May 12 -- last day of guaranteed accommodations YAPC::NA is a grassroots, all-volunteer conference. The speaker quality is high, the participants lively, and there are many extra social activities scheduled. We expect a bit over 400 people this year, and registration is proceeding faster this year than in the past. The registration cost is USD$85. Information on registration: http://yapc.org/America/register-2005.shtml http://yapc.org/America/registration-announcement-2005.txt Direct link to registration: http://donate.perlfoundation.org/index.pl?node=registrant%20info&conference_id=423 Want to be a speaker? Deadline for proposal submission is April 18, just over 1 week from now. Go to: http://yapc.org/America/cfp-2005.shtml Need accommodations in Toronto? Go to: http://yapc.org/America/accommodations-2005.shtml If you book before May 13 you will be guaranteed a hotel space. After that getting accommodations will become progressively more difficult. Prices we have arranged are in two different price ranges: approximately US$50 for a dorm room, US$72 for a decent hotel room. All accommodations are very nearby the conference venue. This message comes from the YAPC::NA 2005 organizers in Toronto.pm, http://to.pm.org/, on behalf of The Perl Foundation, http://www.perlfoundation.org/ We look forward to seeing you in Toronto! If you have any questions please contact na-help@yapc.org From faber at linuxnj.com Mon Apr 25 09:33:32 2005 From: faber at linuxnj.com (Faber Fedor) Date: Mon Apr 25 09:33:48 2005 Subject: [ABE.pm] Printing an array Message-ID: <20050425163332.GA30316@uranus.faber.nom> I've created an array of arrays like this: foreach $a (@{$ary_ref}) { $sum += $a->[1]; # let our data struct be: # decile, cusip, weight, sum push(@deciles, (1, $a->[0], $a->[1], $sum)) if $sum <= 10.0; push(@deciles, (2, $a->[0], $a->[1], $sum)) if $sum <= 20.0 and $sum > 10; push(@deciles, (3, $a->[0], $a->[1], $sum)) if $sum <= 30.0and $sum > 20; push(@deciles, (4, $a->[0], $a->[1], $sum)) if $sum <= 40.0and $sum > 30; push(@deciles, (5, $a->[0], $a->[1], $sum)) if $sum <= 50.0and $sum > 40; push(@deciles, (6, $a->[0], $a->[1], $sum)) if $sum <= 60.0and $sum > 50; push(@deciles, (7, $a->[0], $a->[1], $sum)) if $sum <= 70.0and $sum > 60; push(@deciles, (8, $a->[0], $a->[1], $sum)) if $sum <= 80.0and $sum > 70; push(@deciles, (9, $a->[0], $a->[1], $sum)) if $sum <= 90.0and $sum > 80; push(@deciles, (10, $a->[0], $a->[1], $sum)) if $sum <= 100.0and $sum > 90; } (If anyone has a more elegant way of generating deciles or a better data structure, let me know). Now I want to print out @deciles one "element" (read: array) at a time so that it looks like this: 1 ABC 0.01 0.01 1 DEF 0.02 0.03 ... 10 XXX 43.2 99.99 10 ZZZ 45.0 100.00 but I can't figure out how. When I say open (DECILES, ">deciles_$_->{index}.txt"); for my $i (0..$#deciles){ print DECILES "@{deciles[$i]}\n"; } close(DECILES); I get a \n after each element, e.g. 1 ABC 0.01 0.01 1 DEF 0.02 0.03 ... How can I print this data out in CSV format? Or should I be using some other data structure? TIA -- Regards, Faber Fedor President Linux New Jersey, Inc. 908-320-0357 800-706-0701 http://www.linuxnj.com From faber at linuxnj.com Mon Apr 25 11:07:32 2005 From: faber at linuxnj.com (Faber Fedor) Date: Mon Apr 25 11:07:41 2005 Subject: [ABE.pm] Re: Printing an array In-Reply-To: <20050425163332.GA30316@uranus.faber.nom> References: <20050425163332.GA30316@uranus.faber.nom> Message-ID: <20050425180732.GA30806@uranus.faber.nom> On 25/04/05 12:33 -0400, Faber Fedor wrote: > I've created an array of arrays like this: > > foreach $a (@{$ary_ref}) { > > $sum += $a->[1]; > # let our data struct be: > # decile, cusip, weight, sum > push(@deciles, (1, $a->[0], $a->[1], $sum)) if $sum <= 10.0; > push(@deciles, (2, $a->[0], $a->[1], $sum)) if $sum <= 20.0 and $sum > 10; Changing the above line to read push(@deciles, [2, $a->[0], $a->[1], $sum]) if $sum <= 20.0 and $sum > 10; And now I can get at the data with the $deciles[$i][$j] syntax. Who knew? -- Regards, Faber Fedor President Linux New Jersey, Inc. 908-320-0357 800-706-0701 http://www.linuxnj.com From rjbs-perl-abe at lists.manxome.org Mon Apr 25 18:09:44 2005 From: rjbs-perl-abe at lists.manxome.org (Ricardo SIGNES) Date: Mon Apr 25 18:09:55 2005 Subject: [ABE.pm] Printing an array In-Reply-To: <20050425163332.GA30316@uranus.faber.nom> References: <20050425163332.GA30316@uranus.faber.nom> Message-ID: <20050426010944.GD9950@manxome.org> * Faber Fedor [2005-04-25T12:33:32] > foreach $a (@{$ary_ref}) { > $sum += $a->[1]; > # let our data struct be: > # decile, cusip, weight, sum > push(@deciles, (1, $a->[0], $a->[1], $sum)) if $sum <= 10.0; > push(@deciles, (9, $a->[0], $a->[1], $sum)) if $sum <= 90.0and $sum > 80; > push(@deciles, (10, $a->[0], $a->[1], $sum)) if $sum <= 100.0and $sum > 90; > > } > > (If anyone has a more elegant way of generating deciles or a better data > structure, let me know). Your choice of variable names is unfortunate. $ary_ref tells me nearly nothing, and $a tells me nothing /and/ is usually used by blocks for sort. A minimal improvement might read: for my $datum (@$data) { $sum += $datum->[1]; push @results, [ int($sum / 10), $a->[0], $a->[1], $sum ]; } At least that gets rid of all the C<< if $sum <= y and $sum > z >> crap. -- rjbs -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available Url : http://mail.pm.org/pipermail/abe-pm/attachments/20050425/38cdfc2f/attachment.bin From faber at linuxnj.com Tue Apr 26 06:04:45 2005 From: faber at linuxnj.com (Faber Fedor) Date: Tue Apr 26 06:04:56 2005 Subject: [ABE.pm] Re: Printing an array In-Reply-To: <20050426010944.GD9950@manxome.org> References: <20050425163332.GA30316@uranus.faber.nom> <20050426010944.GD9950@manxome.org> Message-ID: <20050426130445.GA3061@uranus.faber.nom> On 25/04/05 21:09 -0400, Ricardo SIGNES wrote: > * Faber Fedor [2005-04-25T12:33:32] > > foreach $a (@{$ary_ref}) { > > $sum += $a->[1]; > > # let our data struct be: > > # decile, cusip, weight, sum > > push(@deciles, (1, $a->[0], $a->[1], $sum)) if $sum <= 10.0; > > push(@deciles, (9, $a->[0], $a->[1], $sum)) if $sum <= 90.0and $sum > 80; > > push(@deciles, (10, $a->[0], $a->[1], $sum)) if $sum <= 100.0and $sum > 90; > > > > } > > > > (If anyone has a more elegant way of generating deciles or a better data > > structure, let me know). > > Your choice of variable names is unfortunate. > $ary_ref tells me nearly nothing, $ary_ref = = $dbh->selectall_arrayref($stmt); where $stmt = "select rd.cusip, rd.$_->{weight}, fd.cap from table1 rd left join table2 fd on rd.cusip = fd.cusip and rd.realdate = fd.realdate where rd.realdate =\'$date\' and rd.$_->{weight} is not null"; Better? :-) > and $a tells me nothing /and/ is usually used by blocks for > sort. I'm using $a the way I use $i in for loops; it's just a placeholder. > A minimal improvement might read: > > for my $datum (@$data) { > $sum += $datum->[1]; > push @results, [ int($sum / 10), $a->[0], $a->[1], $sum ]; > } > > At least that gets rid of all the C<< if $sum <= y and $sum > z >> crap. Good, cuz' I really want to get rid of that crap. Now, if I can figure out how to access the data by name instead of subscript. -- Regards, Faber Fedor President Linux New Jersey, Inc. 908-320-0357 800-706-0701 http://www.linuxnj.com From phil at five-lawrences.com Tue Apr 26 06:35:11 2005 From: phil at five-lawrences.com (Phil Lawrence) Date: Tue Apr 26 06:38:29 2005 Subject: [ABE.pm] Re: Printing an array In-Reply-To: <20050426130445.GA3061@uranus.faber.nom> References: <20050425163332.GA30316@uranus.faber.nom> <20050426010944.GD9950@manxome.org> <20050426130445.GA3061@uranus.faber.nom> Message-ID: <426E438F.4040701@five-lawrences.com> I'll second the motion; those var names were killing me. I didn't answer because I couldn't bring myself to try and figure out what you were doing! :-/ sorry. > $ary_ref = = $dbh->selectall_arrayref($stmt); if you insist, $aref might be more conventional. Similiarly, you have $href for hash refs. But a real var name is even better, since we'll see it's an aref when you dereference it anyway... > $stmt = "select rd.cusip, rd.$_->{weight}, fd.cap > from table1 rd > left join table2 fd > on rd.cusip = fd.cusip > and rd.realdate = fd.realdate > where rd.realdate =\'$date\' > and rd.$_->{weight} is not null"; YMMV, but I think lining up your SQL makes life *so* much easier, e.g. select rd.cusip, rd.$_->{weight}, fd.cap from table1 rd left join table2 fd on rd.cusip = fd.cusip and rd.realdate = fd.realdate where rd.realdate =\'$date\' and rd.$_->{weight} is not null OR SELECT rd.cusip, rd.$_->{weight}, fd.cap FROM table1 rd LEFT JOIN table2 fd ON rd.cusip = fd.cusip AND rd.realdate = fd.realdate WHERE rd.realdate =\'$date\' AND rd.$_->{weight} IS NOT NULL OR SELECT rd.cusip , rd.$_->{weight} , fd.cap FROM table1 rd LEFT JOIN table2 fd ON rd.cusip = fd.cusip AND rd.realdate = fd.realdate WHERE rd.realdate =\'$date\' AND rd.$_->{weight} IS NOT NULL OR SELECT rd.cusip , rd.$_->{weight} , fd.cap FROM table1 rd NATURAL JOIN table2 fd WHERE realdate =\'$date\' AND rd.$_->{weight} IS NOT NULL > Now, if I can figure out how to access > the data by name instead of subscript. That's what hrefs are for. phil From faber at linuxnj.com Wed Apr 27 17:34:39 2005 From: faber at linuxnj.com (Faber Fedor) Date: Wed Apr 27 17:34:49 2005 Subject: [ABE.pm] Proper module building Message-ID: <20050428003439.GA12205@uranus.faber.nom> Way back when I started this project I'm writing, rjbs suggested I put my common functions into a Perl module. Bowing to his superior wisdom, I did just that and the whole thing is working out fine. However, I'm wondering how to handle the growing number of functions in my .pm. Currently, I export 29 separate functions (I do that by pushing the functions names onto an array and then exporting the array). This method works perfectly fine, but I'm wondering if there is a better way to handle this other than breaking my module up into smaller modules and including all of the smaller modules in my programs or am I doing it the Proper Way? -- Regards, Faber Fedor President Linux New Jersey, Inc. 908-320-0357 800-706-0701 http://www.linuxnj.com