From zookrick at kw.pm.org Fri Jun 10 08:06:51 2005 From: zookrick at kw.pm.org (zookrick@kw.pm.org) Date: Fri, 10 Jun 2005 11:06:51 -0400 Subject: [kw-pm] Meeting Thursday, June 16, 2005 Message-ID: Kitchener-Waterloo Perl Mongers Meeting Thursday, June 16, 2005 Only the Lonely: 10 Overlooked but Useful Core Modules, by Daniel and Eric. (Discussion in the wiki at [1]MeetingTopics). Also this month: Monday, 27 June - Wednesday, 29 June, 2005 [2]YAPC in Toronto. (Local discussion in the wiki at Yapc::NA2005; other discussion on [3]wiki.yapctoronto.org) See our [4]FAQ for more information, or email [5]info at kw.pm.org. References 1. http://kw.pm.org/wiki/index.cgi?MeetingTopics 2. http://www.yapc.org/America/ 3. http://wiki.yapctoronto.org/ 4. http://kw.pm.org/faq.html 5. mailto:info at kw.pm.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/kw-pm/attachments/20050610/d6ca65b9/attachment.html From daniel at coder.com Mon Jun 13 09:45:33 2005 From: daniel at coder.com (Daniel R. Allen) Date: Mon, 13 Jun 2005 12:45:33 -0400 (EDT) Subject: [kw-pm] Meeting Thursday, June 16, 2005 In-Reply-To: Message-ID: And to continue the trend, we have an anonymous pizza-benefactor this month. If you'd like pizza please put your name on kw.pm.org/wiki/index.cgi?PizzaList -Daniel On Fri, 10 Jun 2005 zookrick at kw.pm.org wrote: > > Kitchener-Waterloo Perl Mongers Meeting > > Thursday, June 16, 2005 > > Only the Lonely: 10 Overlooked but Useful Core Modules, by Daniel and > Eric. (Discussion in the wiki at [1]MeetingTopics). > > Also this month: > > Monday, 27 June - Wednesday, 29 June, 2005 > > [2]YAPC in Toronto. (Local discussion in the wiki at Yapc::NA2005; > other discussion on [3]wiki.yapctoronto.org) > > See our [4]FAQ for more information, or email [5]info at kw.pm.org. > > References > > 1. http://kw.pm.org/wiki/index.cgi?MeetingTopics > 2. http://www.yapc.org/America/ > 3. http://wiki.yapctoronto.org/ > 4. http://kw.pm.org/faq.html > 5. mailto:info at kw.pm.org > From dcarr at sdf.lonestar.org Mon Jun 13 21:07:55 2005 From: dcarr at sdf.lonestar.org (lloyd carr) Date: Tue, 14 Jun 2005 04:07:55 +0000 (UTC) Subject: [kw-pm] Meeting Thursday, June 16, 2005 In-Reply-To: References: Message-ID: OK so you go to the Pizza list and you find that Simon is boycotting PizzaPizza. So you say, "Oh, I wonder why Simon is boycotting PizzaPizza?" But wait there's a link, at the end of which will no doubt be the explanation for said boycott, let us follow it and be enlightened. PizzaPizza - "A place that Simon is boycotting" I guess that about sums it up! What more can be said. Simon knows what he is boycotting and that is enough, if it's good enough for Simon or in this case bad enough, it's bad enough for me. I must admit though my imagination does tend to run on when confronted with a vacuum ... Eric there's a Perl program in here, sort of like the fortune program, it randomly gives you the name of a large multinational corporation and pairs it with a random reason for boycotting it. Nothing nearly as Zen as what Simon came up with, but think of the time it would save social activists everywhere ;-) and if it could also automagically fax out a press release annoucing the boycott, well ... On Mon, 13 Jun 2005, Daniel R. Allen wrote: > Date: Mon, 13 Jun 2005 12:45:33 -0400 (EDT) > From: Daniel R. Allen > To: kw-pm at mail.pm.org > Subject: Re: [kw-pm] Meeting Thursday, June 16, 2005 > > And to continue the trend, we have an anonymous pizza-benefactor this > month. > > If you'd like pizza please put your name on > kw.pm.org/wiki/index.cgi?PizzaList > > -Daniel > > On Fri, 10 Jun 2005 zookrick at kw.pm.org wrote: > >> >> Kitchener-Waterloo Perl Mongers Meeting >> >> Thursday, June 16, 2005 >> >> Only the Lonely: 10 Overlooked but Useful Core Modules, by Daniel and >> Eric. (Discussion in the wiki at [1]MeetingTopics). >> >> Also this month: >> >> Monday, 27 June - Wednesday, 29 June, 2005 >> >> [2]YAPC in Toronto. (Local discussion in the wiki at Yapc::NA2005; >> other discussion on [3]wiki.yapctoronto.org) >> >> See our [4]FAQ for more information, or email [5]info at kw.pm.org. >> >> References >> >> 1. http://kw.pm.org/wiki/index.cgi?MeetingTopics >> 2. http://www.yapc.org/America/ >> 3. http://wiki.yapctoronto.org/ >> 4. http://kw.pm.org/faq.html >> 5. mailto:info at kw.pm.org >> > > _______________________________________________ > kw-pm mailing list > kw-pm at pm.org > http://mail.pm.org/mailman/listinfo/kw-pm > dcarr at sdf.lonestar.org SDF Public Access UNIX System - http://sdf.lonestar.org From rpjday at mindspring.com Wed Jun 15 13:33:39 2005 From: rpjday at mindspring.com (Robert P. J. Day) Date: Wed, 15 Jun 2005 16:33:39 -0400 (EDT) Subject: [kw-pm] a philosophical question about hashes Message-ID: not so much a perl question as a software design question that just happens to be associated with perl -- is it considered bad form to create a hash in which each element's key is also one of its fields in the corresponding value? obviously, there would be some redundancy there -- it would be tantamount to, say, having a hash keyed on a social insurance number, and the value being another hash, one of whose elements was, again, the SIN. the duplication there just rubs me the wrong way, but i'm looking at some existing code that has that property and i'm trying to convince myself that there's no real justification for it. thoughts? rday From daniel at coder.com Wed Jun 15 13:49:56 2005 From: daniel at coder.com (Daniel R. Allen) Date: Wed, 15 Jun 2005 16:49:56 -0400 (EDT) Subject: [kw-pm] a philosophical question about hashes In-Reply-To: Message-ID: It might be more convenient to have the key repeated; it doesn't strike me as terribly inelegant. It could make accessing the key back out again, simpler. You could alternately do that by treating the key as a special case when retrieving all the values, but that's a bit more code, by my thinking. -Daniel -- drallen at cs.uwaterloo.ca - Linux software specialist - (519) 888-4567 x6975 http://coder.com/ - Prescient Code Solutions - (519) 575-3733 da at coder.com http://kw.pm.org/ - Kitchener-Waterloo Perl Mongers - da at kw.pm.org On Wed, 15 Jun 2005, Robert P. J. Day wrote: > > not so much a perl question as a software design question that just > happens to be associated with perl -- is it considered bad form to > create a hash in which each element's key is also one of its fields in > the corresponding value? > > obviously, there would be some redundancy there -- it would be > tantamount to, say, having a hash keyed on a social insurance number, > and the value being another hash, one of whose elements was, again, > the SIN. > > the duplication there just rubs me the wrong way, but i'm looking at > some existing code that has that property and i'm trying to convince > myself that there's no real justification for it. > > thoughts? > > rday > _______________________________________________ > kw-pm mailing list > kw-pm at pm.org > http://mail.pm.org/mailman/listinfo/kw-pm > From rpjday at mindspring.com Wed Jun 15 13:54:10 2005 From: rpjday at mindspring.com (Robert P. J. Day) Date: Wed, 15 Jun 2005 16:54:10 -0400 (EDT) Subject: [kw-pm] a philosophical question about hashes In-Reply-To: References: Message-ID: On Wed, 15 Jun 2005, Daniel R. Allen wrote: > It might be more convenient to have the key repeated; it doesn't > strike me as terribly inelegant. > > It could make accessing the key back out again, simpler. You could > alternately do that by treating the key as a special case when > retrieving all the values, but that's a bit more code, by my > thinking. my major concern with repeating the key in the values hash is that it leaves open the possibility of an error somewhere making these two values unequal, which should naturally never happen but now it would at least be technically possible. most of the time, i'm a real big fan of never repeating myself in terms of data definition -- that just leads to trouble. rday From elbie at trig.net Wed Jun 15 14:40:16 2005 From: elbie at trig.net (Christopher Calzonetti) Date: Wed, 15 Jun 2005 17:40:16 -0400 Subject: [kw-pm] a philosophical question about hashes In-Reply-To: References: Message-ID: <20050615214016.GB82035@trig.net> On Wed, Jun 15, 2005 at 04:33:39PM -0400, Robert P. J. Day wrote: > > not so much a perl question as a software design question that just > happens to be associated with perl -- is it considered bad form to > create a hash in which each element's key is also one of its fields in > the corresponding value? I can see at least one reason for doing this: Say there are a bunch of different unique identifiers for a record, and you point to a reference that contains the full record. In your example, you might also have a hash based on driver's license number, and you want to use the same records. Well then, the record would need the SSN/SIN, as it wouldn't be the index. -- Christopher Calzonetti, Technical Lead, Trig.Net Web: http://www.trig.net/ Mail: mailto:chris at trig.net From rpjday at mindspring.com Wed Jun 15 16:30:05 2005 From: rpjday at mindspring.com (Robert P. J. Day) Date: Wed, 15 Jun 2005 19:30:05 -0400 (EDT) Subject: [kw-pm] a philosophical question about hashes In-Reply-To: <20050615214016.GB82035@trig.net> References: <20050615214016.GB82035@trig.net> Message-ID: On Wed, 15 Jun 2005, Christopher Calzonetti wrote: > On Wed, Jun 15, 2005 at 04:33:39PM -0400, Robert P. J. Day wrote: > > > > not so much a perl question as a software design question that just > > happens to be associated with perl -- is it considered bad form to > > create a hash in which each element's key is also one of its fields in > > the corresponding value? > > I can see at least one reason for doing this: > > Say there are a bunch of different unique identifiers for a record, > and you point to a reference that contains the full record. > > In your example, you might also have a hash based on driver's > license number, and you want to use the same records. Well then, > the record would need the SSN/SIN, as it wouldn't be the index. i'd thought of that as well. i *can* see the value in the duplication, i was just wondering if anyone had strong opinions on this either way. rday From Greg.Fenton at sybase.com Thu Jun 16 07:51:39 2005 From: Greg.Fenton at sybase.com (Greg.Fenton@sybase.com) Date: Thu, 16 Jun 2005 10:51:39 -0400 Subject: [kw-pm] a philosophical question about hashes In-Reply-To: Message-ID: [Sorry if this is a dupe....our IT organization cannot keep our domain name straight so some posts have been bouncing] To me, this is a "normalization" question, akin to relational database normalization. The ultimate goal of any database design is to be as normalized as possible, reducing duplication and segmenting data into tightly focused groupings. However, there are certainly patterns in relational design where over-normalization leads to poor performance or unwieldly complex code (queries). To that end, there are definitely times where denormalization makes complete sense (reality vs. purism). greg.fenton ---- Greg Fenton Consultant, Solution Services iAnywhere Solutions "Robert P. J. Day" Sent by: kw-pm-bounces at pm.org 06/15/2005 07:30 PM To Christopher Calzonetti cc KW Perl list Subject Re: [kw-pm] a philosophical question about hashes On Wed, 15 Jun 2005, Christopher Calzonetti wrote: > On Wed, Jun 15, 2005 at 04:33:39PM -0400, Robert P. J. Day wrote: > > > > not so much a perl question as a software design question that just > > happens to be associated with perl -- is it considered bad form to > > create a hash in which each element's key is also one of its fields in > > the corresponding value? > > I can see at least one reason for doing this: > > Say there are a bunch of different unique identifiers for a record, > and you point to a reference that contains the full record. > > In your example, you might also have a hash based on driver's > license number, and you want to use the same records. Well then, > the record would need the SSN/SIN, as it wouldn't be the index. i'd thought of that as well. i *can* see the value in the duplication, i was just wondering if anyone had strong opinions on this either way. rday _______________________________________________ kw-pm mailing list kw-pm at pm.org http://mail.pm.org/mailman/listinfo/kw-pm -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/kw-pm/attachments/20050616/b5fa3311/attachment.html From john at perlwolf.com Thu Jun 16 10:37:32 2005 From: john at perlwolf.com (John Macdonald) Date: Thu, 16 Jun 2005 13:37:32 -0400 Subject: [kw-pm] a philosophical question about hashes In-Reply-To: References: Message-ID: <20050616173732.GA13272@lupus.perlwolf.com> There are certainly times when having the key inside the value is useful. If you have a subroutine that operates on a single value record, it could easily need to know the value of the key as well as the others parts of the record. It's easier to pass it a single coherent value than to have to pass the key as well. process_record( $structure{$_} ) for (@interesting_keys); On Thu, Jun 16, 2005 at 10:51:39AM -0400, Greg.Fenton at sybase.com wrote: > [Sorry if this is a dupe....our IT organization cannot keep our domain > name straight so some posts have been bouncing] > > To me, this is a "normalization" question, akin to relational database > normalization. The ultimate goal of any database design is to be as > normalized as possible, reducing duplication and segmenting data into > tightly focused groupings. > > However, there are certainly patterns in relational design where > over-normalization leads to poor performance or unwieldly complex code > (queries). To that end, there are definitely times where denormalization > makes complete sense (reality vs. purism). > > greg.fenton > ---- > Greg Fenton > Consultant, Solution Services > iAnywhere Solutions > > > > "Robert P. J. Day" > Sent by: kw-pm-bounces at pm.org > 06/15/2005 07:30 PM > > To > Christopher Calzonetti > cc > KW Perl list > Subject > Re: [kw-pm] a philosophical question about hashes > > > > > > > On Wed, 15 Jun 2005, Christopher Calzonetti wrote: > > > On Wed, Jun 15, 2005 at 04:33:39PM -0400, Robert P. J. Day wrote: > > > > > > not so much a perl question as a software design question that just > > > happens to be associated with perl -- is it considered bad form to > > > create a hash in which each element's key is also one of its fields in > > > the corresponding value? > > > > I can see at least one reason for doing this: > > > > Say there are a bunch of different unique identifiers for a record, > > and you point to a reference that contains the full record. > > > > In your example, you might also have a hash based on driver's > > license number, and you want to use the same records. Well then, > > the record would need the SSN/SIN, as it wouldn't be the index. > > i'd thought of that as well. i *can* see the value in the > duplication, i was just wondering if anyone had strong opinions on > this either way. > > rday > _______________________________________________ > kw-pm mailing list > kw-pm at pm.org > http://mail.pm.org/mailman/listinfo/kw-pm > > > _______________________________________________ > kw-pm mailing list > kw-pm at pm.org > http://mail.pm.org/mailman/listinfo/kw-pm -- From rpjday at mindspring.com Thu Jun 16 10:30:11 2005 From: rpjday at mindspring.com (Robert P. J. Day) Date: Thu, 16 Jun 2005 13:30:11 -0400 (EDT) Subject: [kw-pm] a philosophical question about hashes In-Reply-To: <20050616173732.GA13272@lupus.perlwolf.com> References: <20050616173732.GA13272@lupus.perlwolf.com> Message-ID: On Thu, 16 Jun 2005, John Macdonald wrote: > There are certainly times when having the key inside the value is > useful. If you have a subroutine that operates on a single value > record, it could easily need to know the value of the key as well as > the others parts of the record. It's easier to pass it a single > coherent value than to have to pass the key as well. > > process_record( $structure{$_} ) for (@interesting_keys); in the general case, of course, if i want multiple keys, i'd create a hash value structure that contained all of those key values, then just create distinct hashes for each key. but i don't think i need to get that carried away just yet. rday From john at perlwolf.com Thu Jun 16 10:49:14 2005 From: john at perlwolf.com (John Macdonald) Date: Thu, 16 Jun 2005 13:49:14 -0400 Subject: [kw-pm] a philosophical question about hashes In-Reply-To: References: <20050616173732.GA13272@lupus.perlwolf.com> Message-ID: <20050616174914.GA13437@lupus.perlwolf.com> On Thu, Jun 16, 2005 at 01:30:11PM -0400, Robert P. J. Day wrote: > On Thu, 16 Jun 2005, John Macdonald wrote: > > > There are certainly times when having the key inside the value is > > useful. If you have a subroutine that operates on a single value > > record, it could easily need to know the value of the key as well as > > the others parts of the record. It's easier to pass it a single > > coherent value than to have to pass the key as well. > > > > process_record( $structure{$_} ) for (@interesting_keys); > > in the general case, of course, if i want multiple keys, i'd create a > hash value structure that contained all of those key values, then just > create distinct hashes for each key. but i don't think i need to get > that carried away just yet. That would depend upon whether the list of keys had long term significance or whether they just happened to be of momentary interest. (Instead of "@interesting_keys" you might have "grep /foo.*bar/, keys %structure" as the for iterator.) Regardless, my point was that just as a select from a database returns complete records, *including the key field(s)*, it is useful for the value object to contain the complete record if it is a useful data structure in its own right. -- From daniel at coder.com Thu Jun 16 20:22:04 2005 From: daniel at coder.com (Daniel R. Allen) Date: Thu, 16 Jun 2005 23:22:04 -0400 (EDT) Subject: [kw-pm] slides Message-ID: Slides from the talk(s) we gave tonight are up: http://kw.pm.org/talks/0605-OnlyTheLonely/ ...unfortunately it does not include Matt's impromptu discussion of how pseudo-hashes really work, nor Simon's challenge to solve his finite state (?) problem and the various suggestions from the peanut gallery. The beer afterward will be left as an exercise for the reader. ...Thanks all, it was loads of fun. -Daniel p.s. - the Catalyst web framework looks very interesting as a new MVC, thanks to Matt (?) for suggesting it... http://www.perl.com/pub/a/2005/06/02/catalyst.html From fhew3 at cogeco.ca Thu Jun 16 21:01:45 2005 From: fhew3 at cogeco.ca (Fulko Hew) Date: Fri, 17 Jun 2005 00:01:45 -0400 Subject: [kw-pm] YAPC volunteers needed Message-ID: <42B24B29.5050309@cogeco.ca> This is just a reminder that we still need volunteers to help out at YAPC. There are still a few seminars that don't have _anybody_ signed up to help. Please don't be frightened by the tasks. They're easy and you'll have plenty of support. But we do need those volunteers! This is your chance for fame and ... Go to the signup sheet at: http://hew.ca/yapc.html click on the various days, and use the volunteer button to sign up for the tasks and seminars that haven't been taken yet. More instructions on how to use the sign-up mechanism and more detailed descriptions of the tasks can be found at: http://to.pm.org/cgi-bin/kwiki/index.pl?VolunteerSignUp From fhew3 at cogeco.ca Thu Jun 16 21:11:47 2005 From: fhew3 at cogeco.ca (Fulko Hew) Date: Fri, 17 Jun 2005 00:11:47 -0400 Subject: [kw-pm] Call for volunteer YAPC proceedings "CD burners" Message-ID: <42B24D83.7080101@cogeco.ca> We are considering pre-burning CDs with the presentation slides (only) of this years YAPC for inclusion in the swag-bag handed out during registration. (Full material including photos and recordings will be made available after the conference is over, but we would like to put something in everyone's bag if we can.) If we get the material in-time, we need someone with the facilities to burn 400+ copies between next Thursday and Sunday. Does anyone have facilities? Does anyone want to volunteer to take on this job? If you feel up to it, send me an email. Fulko From simon-kwpm at uc.org Thu Jun 16 21:23:26 2005 From: simon-kwpm at uc.org (simon-kwpm@uc.org) Date: Fri, 17 Jun 2005 00:23:26 -0400 (EDT) Subject: [kw-pm] irc Message-ID: For those who were curious about the IRC channel fish, daniel, and myself frequent, it's irc.byxnet.net, #uc The waterloo hub is irc.yossman.net. It's a quiet network, there's a small #perl channel there too. If you aren't familiar with IRC, you can visit http://irc.uc.org and connect using a Java applet. Cheers, Simon From fhew3 at cogeco.ca Thu Jun 16 21:25:25 2005 From: fhew3 at cogeco.ca (Fulko Hew) Date: Fri, 17 Jun 2005 00:25:25 -0400 Subject: [kw-pm] Call (...still...) for YAPC recording equipment Message-ID: <42B250B5.20107@cogeco.ca> This is my second call for volunteered equipment to allow us to record the various sessions during this years YAPC. I'm looking for: a) Three laptops with a CD drive, Ethernet, and 256M memory to act as the audio recording hardware. (So far I have 1 guaranteed and tested, and 2 pledged but untested (Alex... please test them!) b) Three laptops with a CD drive, Ethernet, 256M memory AND firewire, to act as the video recording hardware. (So far I have only 1 guaranteed and tested. I need TWO more!) c) Three 'digital video' cameras that have firewire output and a 'mic' jack input. (So far I have 2 guaranteed and tested, and I need one more.) If I can't get three video recording PCs, then I still want 3 cameras and the loan of a whack of tape to at least record it all for later digitization. Maybe up to 32 hrs worth of tape!. If you can help in any way, send me an email. From glim at mycybernet.net Thu Jun 16 21:52:00 2005 From: glim at mycybernet.net (Gerard Lim) Date: Fri, 17 Jun 2005 00:52 -0400 Subject: [kw-pm] Last-minute reminder -- YAPC::NA 2005 Message-ID: Here's a last reminder about Yet Another Perl Conference, North America (YAPC::NA 2005) http://yapc.org/America In case anyone out there has been sitting on the fence or has been meaning to register but has put it on the backburner until now, here is a final information package. Dates: Mon - Wed June 27 - 29, 2005 (11 days from now!) Location: 89 Chestnut Street, University of Toronto, Toronto, Ontario, Canada Accommodations ============== Due to recent renegotiations with the conference facility and hotel, 89 Chestnut, there are still a few rooms left. For details on accommodations go to: http://www.yapc.org/America/accommodations-2005.shtml For quick and easy booking: 89 Chestnut Phone: +1-416-977-0707 Conference booking code: perl0626 The base rate is approx. CAD$80/night, which is *great* for downtown Toronto. Add in taxes and in-room high speed internet and it's up to about CAD$95/night. Book yourself to check-in on Sunday the 26th and check-out on the morning of Wednesday the 29th. Conference Registration ======================= Registration is easy and cheap - only USD$85 - see http://yapc.org/America/register-2005.shtml for details or register directly online at http://donate.perlfoundation.org/index.pl?node=registrant%20info&conference_id=423 The schedule is awesome - http://yapc.org/America/schedule-2005/day1.html >From here, click on the "Day 2" and "Day 3" spots near the top to go from page to page. Click on a talk name to get details regarding the talk. Speakers include Larry Wall, Allison Randal, Autrijus Tang, Brian Ingerson, Andy Lester, chromatic, brian d foy, Chip Salzenberg & Dan Sugalski... and many more! [ This message was sent by Gerard Lim on behalf of the YAPC::NA 2005 Conference organizing committee of the Toronto Perl Mongers. Thanks for your patience and support. ] From matt at sergeant.org Fri Jun 17 07:36:11 2005 From: matt at sergeant.org (Matt Sergeant) Date: Fri, 17 Jun 2005 10:36:11 -0400 Subject: [kw-pm] Pseudo Hashes (Was Re: slides) In-Reply-To: References: Message-ID: <901cddb05db77563542520822a3a7b51@sergeant.org> OK, so I'll repeat the pseudohashes thingy here: Problem statement: You have an object as a hashref, but there's a performance penalty for looking up values in a hash (compute the hash, lookup the entry in the hash buckets, including cascading into overflow buckets if required). Now you can have your objects as blessed arrays no problem: package Person; use constant NAME => 0; use constant AGE => 1; use constant SEX => 2; sub new { bless [], shift; } And the access is fast, keyed off constants, and thus key-safe. But this is truly horrible for subclassing - you have to remember to add entries starting at 3, and if the base class gets extended it all breaks really badly. Note this is how I wrote XML::XPath. XML::Twig uses a similar scheme, but the source code uses hashrefs, and mirod magically filters it all into arrayrefs when he runs Makefile.PL. Kinda sick, but works. So to solve this in a more elegant (*cough*) way, the perl5-porters came up with the idea of pseudohashes. The basic premise is the construction of the pseudohash hashref is really an arrayref that looks like this: [ { name => 1, age => 2, sex => 3 }, "John Doe", 22, "Male" ] And when you treat it like a hash perl automatically does the right thing in order to find your elements: $self->{name} becomes $self->[$self->[0]{name}] This isn't much of an optimisation (it's slower than an ordinary hash lookup), so in order to make this really fast perl has to be able to precompute the hash entries. You can do this with the fields pragma and by specifying the class of the $self var. package Person; use fields qw(name age sex); sub new { my Person $self = shift; $self = fields::new($self) unless ref($self); return $self; } Now the important thing to remember is that everywhere you use $self (i.e. in all your methods) you MUST declare it as "my Person $self" otherwise you don't get the optimisation - you get the slow version. This all sounds great, but what are the downsides? - It's a mess. It's a really ugly hack. You can accidentally use $self as an arrayref instead of a hashref and perl won't complain. - You can't delete() keys. In fact doing so results in some really weird bugs under older versions of perl. You have to undef() keys. - exists() doesn't work right either. - local $r->{key} doesn't work right either. - Imagine you have $r->[ { 1 => \$y }, { 2 => \$z } ] (or something like that). Now you accidentally type $r->{1} in your program instead of $r->[1] - what happens? Perl thinks you want a pseudo hash. So it looks up the key 1 in your 0'th element, finds \$y. Since it's a reference, it's something like SCALAR(0x809f0c). But if you treat it as a number it's 8429324. So perl happily goes and tries to look up an array element nearly 8 and a half million entries away. And expands the array to accomodate. Yow! If you're careful they can actually give you a small performance boost (I use them in the high_perf branch of qpsmtpd which is what we run on our spamtrap), but if you're not careful they get really horrid really fast :-) From dcarr at sdf.lonestar.org Sat Jun 18 05:10:40 2005 From: dcarr at sdf.lonestar.org (lloyd carr) Date: Sat, 18 Jun 2005 12:10:40 +0000 (UTC) Subject: [kw-pm] irc In-Reply-To: References: Message-ID: New to IRC and don't seem to be able to connect with JAVA client or chatzilla. HELP! - Lloyd On Fri, 17 Jun 2005 simon-kwpm at uc.org wrote: > Date: Fri, 17 Jun 2005 00:23:26 -0400 (EDT) > From: simon-kwpm at uc.org > To: kw-pm at mail.pm.org > Subject: [kw-pm] irc > > For those who were curious about the IRC channel fish, daniel, and myself > frequent, it's irc.byxnet.net, #uc > > The waterloo hub is irc.yossman.net. It's a quiet network, there's a > small #perl channel there too. > > If you aren't familiar with IRC, you can visit http://irc.uc.org and > connect using a Java applet. > > Cheers, > Simon > _______________________________________________ > kw-pm mailing list > kw-pm at pm.org > http://mail.pm.org/mailman/listinfo/kw-pm > dcarr at sdf.lonestar.org SDF Public Access UNIX System - http://sdf.lonestar.org From simon-kwpm at uc.org Sat Jun 18 06:49:38 2005 From: simon-kwpm at uc.org (simon-kwpm@uc.org) Date: Sat, 18 Jun 2005 09:49:38 -0400 (EDT) Subject: [kw-pm] irc In-Reply-To: References: Message-ID: Gah! The irc hub is down. Try one of the spokes: anarchy.tamu.edu Cheers, Simon On Sat, 18 Jun 2005, lloyd carr wrote: > New to IRC and don't seem to be able to connect with JAVA client or > chatzilla. HELP! > > - Lloyd > > On Fri, 17 Jun 2005 simon-kwpm at uc.org wrote: > > > Date: Fri, 17 Jun 2005 00:23:26 -0400 (EDT) > > From: simon-kwpm at uc.org > > To: kw-pm at mail.pm.org > > Subject: [kw-pm] irc > > > > For those who were curious about the IRC channel fish, daniel, and myself > > frequent, it's irc.byxnet.net, #uc > > > > The waterloo hub is irc.yossman.net. It's a quiet network, there's a > > small #perl channel there too. > > > > If you aren't familiar with IRC, you can visit http://irc.uc.org and > > connect using a Java applet. > > > > Cheers, > > Simon > > _______________________________________________ > > kw-pm mailing list > > kw-pm at pm.org > > http://mail.pm.org/mailman/listinfo/kw-pm > > > > dcarr at sdf.lonestar.org > SDF Public Access UNIX System - http://sdf.lonestar.org > From rpjday at mindspring.com Wed Jun 22 04:46:09 2005 From: rpjday at mindspring.com (Robert P. J. Day) Date: Wed, 22 Jun 2005 07:46:09 -0400 (EDT) Subject: [kw-pm] but i just put in a "print" statement. really! Message-ID: ok, this is the same thing you'd normally never believe but, i swear, adding a simple "print" statement to a perl module for debugging purposes suddenly made the program work. i have a hash with entries of the form: key => (reference to value hash with numerous fields) and my subroutine accepts nothing more than a reference to the top-level hash, and a string to search for as the value for one of the fields in the hash that's the value corresponding to that key. really, it's just that simple -- a "while each" loop through the hash, for each key, get the reference to the value hash, and dereference that to get to the field in question, then a string compare. however, after i initially loaded the hash and verified a number of entries, i started searching. the first time i looked for a particular value, the search routine found it. the *second* time, however, it failed to find it, and a dump of the hash showed, sure enough, no such entry. whaaaa? after much debugging and head scratching, since the hash was fairly sizable, i added a simple "print" statement to the top of the search routine to print the number of keys in the hash, to see if suddenly there were unexpectedly fewer keys, so i added the following: print "Currently, hash has " . (scalar keys %$href) . " elements.\n" ; lo and behold, suddenly the program starts to work properly. what the hell? the only imaginable side effect is just taking the keys of the hash, so i replaced that statement with: my @keys = keys %$href ; and that *also* solved the problem. so it appears that there's some kind of side effect associated with just taking the keys of a hash. i don't know what else to think. i didn't write the rest of the surrounding code, so is it possible that, elsewhere, a hash entry was deleted and taking the keys somehow "cleans up" or reorganizes the hash. i know very well that you shouldn't mess with the keys of a hash while iterating through it, but i don't (at first glance) see that happening anywhere. i'm just puzzled about what might be happening. thoughts? rday From Greg.Fenton at sybase.com Wed Jun 22 05:27:22 2005 From: Greg.Fenton at sybase.com (Greg.Fenton@sybase.com) Date: Wed, 22 Jun 2005 05:27:22 -0700 Subject: [kw-pm] but i just put in a "print" statement. really! Message-ID: Just to be sure...have you tried removing this hack to see if the problem returns? (I'm currently at a customer site where they can no longer repro the problem now that I had them remove the "only change we made" since hitting the problem...) greg.fenton -- Greg Fenton Principal Solutions Consultant iAnywhere Solutions http://www.ianywhere.com/ ----- Original Message ----- From: kw-pm-bounces Sent: 06/22/2005 04:46 AM To: KW Perl list Subject: [kw-pm] but i just put in a "print" statement. really! ok, this is the same thing you'd normally never believe but, i swear, adding a simple "print" statement to a perl module for debugging purposes suddenly made the program work. i have a hash with entries of the form: key => (reference to value hash with numerous fields) and my subroutine accepts nothing more than a reference to the top-level hash, and a string to search for as the value for one of the fields in the hash that's the value corresponding to that key. really, it's just that simple -- a "while each" loop through the hash, for each key, get the reference to the value hash, and dereference that to get to the field in question, then a string compare. however, after i initially loaded the hash and verified a number of entries, i started searching. the first time i looked for a particular value, the search routine found it. the *second* time, however, it failed to find it, and a dump of the hash showed, sure enough, no such entry. whaaaa? after much debugging and head scratching, since the hash was fairly sizable, i added a simple "print" statement to the top of the search routine to print the number of keys in the hash, to see if suddenly there were unexpectedly fewer keys, so i added the following: print "Currently, hash has " . (scalar keys %$href) . " elements.\n" ; lo and behold, suddenly the program starts to work properly. what the hell? the only imaginable side effect is just taking the keys of the hash, so i replaced that statement with: my @keys = keys %$href ; and that *also* solved the problem. so it appears that there's some kind of side effect associated with just taking the keys of a hash. i don't know what else to think. i didn't write the rest of the surrounding code, so is it possible that, elsewhere, a hash entry was deleted and taking the keys somehow "cleans up" or reorganizes the hash. i know very well that you shouldn't mess with the keys of a hash while iterating through it, but i don't (at first glance) see that happening anywhere. i'm just puzzled about what might be happening. thoughts? rday _______________________________________________ kw-pm mailing list kw-pm at pm.org http://mail.pm.org/mailman/listinfo/kw-pm From rpjday at mindspring.com Wed Jun 22 05:33:31 2005 From: rpjday at mindspring.com (Robert P. J. Day) Date: Wed, 22 Jun 2005 08:33:31 -0400 (EDT) Subject: [kw-pm] but i just put in a "print" statement. really! In-Reply-To: References: Message-ID: On Wed, 22 Jun 2005 Greg.Fenton at sybase.com wrote: > Just to be sure...have you tried removing this hack to see if the > problem returns? fer shure. several times. rday From daniel at coder.com Thu Jun 30 17:29:03 2005 From: daniel at coder.com (Daniel R. Allen) Date: Thu, 30 Jun 2005 20:29:03 -0400 (EDT) Subject: [kw-pm] thoughts about yapc? Message-ID: My review of YAPC is up on use.perl, the 4 most recent entries: http://use.perl.org/~da/journal/ ...of course we'll talk about it at our bbq in 3 weeks or so; but I thought we might want to talk a bit before we forget most of it. :) -Daniel