From jazzdev at gmail.com Mon Jan 2 01:29:44 2006 From: jazzdev at gmail.com (JD Brennan) Date: Mon, 2 Jan 2006 01:29:44 -0800 Subject: SPUG: new CPAN shell and LWP::Simple In-Reply-To: <20060101071302.GC5384@efn.org> References: <90DCDC0B-7968-11DA-8BA5-000A95719C94@sedition.com> <20060101071302.GC5384@efn.org> Message-ID: Sounds like you just need to use cpan to install HTML::Tagset I like to setup cpan to automatically follow dependencies, but that's not the default. JD On 12/31/05, Yitzchak Scott-Thoennes wrote: > On Fri, Dec 30, 2005 at 09:37:03PM -0800, Ramon Hildreth wrote: > > Hi A, > > > > Thanks for the tip. I got further this time I think, but ran into > > trouble here: > > > > --- > > live/validator.........Can't locate HTML/Tagset.pm in @INC (@INC > > libwww-perl requires (URI and) HTML-Parser, which requires HTML-Tagset. > _____________________________________________________________ > Seattle Perl Users Group Mailing List > POST TO: spug-list at pm.org > SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list > MEETINGS: 3rd Tuesdays, Location: Amazon.com Pac-Med > WEB PAGE: http://seattleperl.org/ > From jobs-noreply at seattleperl.org Thu Jan 5 14:17:06 2006 From: jobs-noreply at seattleperl.org (SPUG Jobs) Date: Thu, 5 Jan 2006 14:17:06 -0800 (PST) Subject: SPUG: JOB: Perl Developer with downtown Seattle company via recruiter Message-ID: Exciting Opportunity for a Perl Developer Lincoln Bay is an IT Staffing Company located in downtown Seattle. We are currently working with a client in Seattle that has an opening for a Perl Developer. This developer will be responsible for web application customization. These web applications will be in support of the primary sales incentive/service product offered by the company. This is a great opportunity for a mid-level developer with a growing company. The platform is PHP/Perl/MySQL. If you are strong in Perl development I would love to talk with you. The position will be contract to permanent. The contract period will be anywhere from 30-90 days. The contract rate will be between $35/hr-$40/hr and $65,000-$70,000/yr on the permanent side. Please send a resume to nicoles at lincolnbay.com or call me directly at 206-438-5704. Nicole Seaver Recruiter | Lincoln Bay 1000 2nd Avenue Suite 1900 - Seattle 206-438-5704 - direct 206-438-5711 - fax nicoles at lincolnbay.com From dblanchard at gmail.com Mon Jan 9 14:23:49 2006 From: dblanchard at gmail.com (Duane Blanchard) Date: Mon, 9 Jan 2006 14:23:49 -0800 Subject: SPUG: Happy New Year, let's meet again this month Message-ID: Merry Christmas and other holiday greetings to all, Last month was a great get-to-know-each-other meeting downtown at the WhitePages.com office, thanks Craig for a sweet setup and thanks all the WhitePages people who made the room seem just the right size. I was worried that being so close to Christmas and Hanukkah and all, we would only have a few people, but the turn out was great. Everyone who spoke up there wanted to meet again in January, and said they would like a couple tutorials or technical discussions this month. So, if you'd like to volunteer, let us know as soon as you can. Even if you can't lead a discussion/tutorial this month but would be interested in one for coming months, please let us know. It seems to make sense to run the next several meetings at WhitePages.com again but to start a little later. I was late myself, and apologize again. I think street parking becomes free after 6:00, and that it starts filling up on streets that are closed for parking during day about 15 minutes before they are officially open. Can anyone in Seattle tell us whether street parking opens at 6:00 also? Also, someone had a tip for a cheap place to pay for parking; would you mind reminding me where that was? Thanks. The date, following convention, will be the 17th. I hope to see everyone there. Thanks all, D -- Duane Blanchard 206.280.1263 There are 10 kinds of people in the world; those who know binary and those who don't. From dan at concolor.org Mon Jan 9 15:00:25 2006 From: dan at concolor.org (Daniel Sabath) Date: Mon, 9 Jan 2006 15:00:25 -0800 Subject: SPUG: Happy New Year, let's meet again this month In-Reply-To: References: Message-ID: On Jan 9, 2006, at 2:23 PM, Duane Blanchard wrote: > > It seems to make sense to run the next several meetings at > WhitePages.com again but to start a little later. I was late myself, > and apologize again. I think street parking becomes free after 6:00, > and that it starts filling up on streets that are closed for parking > during day about 15 minutes before they are officially open. Can > anyone in Seattle tell us whether street parking opens at 6:00 also? > Also, someone had a tip for a cheap place to pay for parking; would > you mind reminding me where that was? Thanks. > Street parking does indeed open at 6pm. I usually have no difficulty finding it between 5:55 and 6:10. If I can't park on the street, then Pacific Place is usually between 3$ and 5$ after 5pm. I think the price break is at the 4th hour. Dan From m3047 at inwa.net Tue Jan 10 10:26:20 2006 From: m3047 at inwa.net (Fred Morris) Date: Tue, 10 Jan 2006 10:26:20 -0800 Subject: SPUG: Unidentified Flying Objects Message-ID: When I contemplate doing something odd, and particularly if it seems brilliant, I like to take a step back and ask two questions: 1) Can I explain it to another human being? 2) How would I implement this in some other environment? So I am going to try to explain this, and then at the end there is a little standalone Perl script which runs and demonstrates just how easy it is to change the class of an object in midair using Perl. So my questions are: 1) After reading this through, does it make a bit of sense? :-p 2) I can think of ways to do this with things like a busybox or a container with snapins (the last bastions of OO zealots who can't admit that sometimes a callback is just a callback... regardless of whether the object in question is disc-shaped or cigar-shaped), but are there any other languages (particularly agile languages) which make it this as seductively easy? Can you do this in Python (just a dabbler, me)? Ruby? What about Perl 6? "Unidentified Flying Object": that's an oxymoron, isn't it? You've identified it as a flying object (look, up in the sky...). For that matter you've identified it as "unidentified". Maybe being unidentified gives it some special properties such as telling other air traffic to give it a wide berth, and if it disappears suddenly off of radar to send the Marines instead of an ambulance. Maybe you just don't really care, and identifying it as "unidentified" is good enough for your purposes. What if you make a mistake (it's a bird, no it's a plane..)? Wouldn't it be nice to fix that as easily as saying "no, it's something else"? In the actual case at hand there is a base class which implements various scripts for behaviors, and the subclasses provide methods which are combined to implement those behaviors. Most of the time you know what something is. But sometimes you don't yet in the course of executing a behavior it becomes obvious what it is. The script which follows does this in a most brutal fashion by calling the same method twice, once before transmogrification and once afterwards; in practice the internal methods resemble more a series of steps. -- Fred Morris http://www.inwa.net/~m3047/contact.html -- #!/usr/bin/perl -w use strict; package Flyer; sub new { my $class = shift; my $self = { }; return bless $self, $class; } # &new sub zap { my $self = shift; my $new_me = shift; print "ZAP!\n"; return bless $self, $new_me; } # &zap sub i_am_a { my $self = shift; return "I'd tell you but then I'd have to kill -9 you"; } # &i_am_a sub on_a_typical_day { my $self = shift; my $new_me = shift; print 'I am a ' . $self->i_am_a() . "\n"; $self->zap( $new_me ); print 'I am a ' . $self->i_am_a() . "\n"; } # &on_a_typical_day package Bird; use vars qw/ @ISA /; @ISA = qw/ Flyer /; sub i_am_a { my $self = shift; return "bird, with feathers"; } # &i_am_a package Plane; use vars qw/ @ISA /; @ISA = qw/ Flyer /; sub i_am_a { my $self = shift; return "plane, with engines"; } # &i_am_a # -=-=- let the show begin -=-=- package main; my $ufo = Bird->new(); $ufo->on_a_typical_day( 'Plane' ); exit(0) __END__ From AEH at akc.org Tue Jan 10 11:21:08 2006 From: AEH at akc.org (Adrian Hands) Date: Tue, 10 Jan 2006 14:21:08 -0500 Subject: SPUG: Unidentified Flying Objects Message-ID: <862E491E88FFFE44846C445B4881DD7C31FB25@PUG.ad.akc.org> > something is. But sometimes you don't yet in the course of executing a > behavior it becomes obvious what it is. so, you do a cast, but from Flyer to Plane (or Flyer to Bird), but not Bird to Plane. Flyer ufo = new Bird(); ( (Plane) ufo ).on_a_typical_day(); // you'll get a ClassCastException at runtime. When is it a good idea to change a bird into a plane? From m3047 at inwa.net Tue Jan 10 11:57:27 2006 From: m3047 at inwa.net (Fred Morris) Date: Tue, 10 Jan 2006 11:57:27 -0800 Subject: SPUG: Unidentified Flying Objects Message-ID: At 2:21 PM 1/10/06, Adrian Hands wrote: >I wrote: >> [...]something is. But sometimes you don't yet in the course of executing a >> behavior it becomes obvious what it is. > >so, you do a cast, but from Flyer to Plane (or Flyer to Bird), but not >Bird to Plane. > > Flyer ufo = new Bird(); > ( (Plane) ufo ).on_a_typical_day(); > // you'll get a ClassCastException at runtime. No. It is not a cast. It is a zen thing: it is not a bird wearing an airplane's clothes, it changes from a bird into a plane. With enough template hacking maybe somebody can do it in C++; I'd be afraid. Again, it is not a cast (which to me implies temporarily cloaking an object in the appearance of another, typically to fool a compiler and not to directly alter execution). It is something, however, which is conceivable in a semi-interpreted language such as Perl where class is simply an attribute which is bound to a reference (reference as a general concept, as opposed to a narrow definition such as a container for a memory address); in fact I would have been far more surprised if it hadn't worked. There is an old quote somewhere that C++ is to C as lung cancer is to lung. In this case the adage might be Perl is to OO as C is to assembler. (If comparing C to assembler seems silly to you, you need only look at the C compilers released for free-running microprocessors with a whopping 8K of flash and 256 bytes of RAM... or reflect on the processor which C was originally developed for.) So the question: "can I do this in another implementation environment" == "how processor-specific is this". >When is it a good idea to change a bird into a plane? And the answer is when it becomes a plane. Is that the right question? When is it a good idea to eat lunch? (Your truncation to "...something is" is serendipitous.) It is not the object which changes, but our perception of it. The code is neither the bird nor the plane, but our perception of it. It's a zen thing. I appreciate your asking, but the question I would ask is: when is it worth doing something brilliant as opposed to upholding rigid conventions or belief systems which in and of themselves may fail your "good idea" test? Is it a good idea to construct your own bird, or is it better to let them hatch from eggs? Planes, of course, don't hatch from eggs; yet the ontology of the development of mechanized flight certainly reveals its inspiration from the natural world. I would proffer that doing something like this requires developing some appropriate style guidelines so that you don't for example, change a bird into a rock: something which Perl would also allow (it enforces no discernible constraints on what an object can be changed into, for instance must be a subclass of the same base class.. the potential for mayhem is I hope obvious, it is to me). From jazzdev at gmail.com Tue Jan 10 12:15:12 2006 From: jazzdev at gmail.com (JD Brennan) Date: Tue, 10 Jan 2006 12:15:12 -0800 Subject: SPUG: Unidentified Flying Objects In-Reply-To: References: Message-ID: On 1/10/06, Fred Morris wrote: > > > sub zap { > > my $self = shift; > my $new_me = shift; > > print "ZAP!\n"; > > return bless $self, $new_me; Yeah, that's odd. Calling bless more than once. That is kinda cool. I don't think you can do that in Ruby. Perl is strange that way. An object is just a reference to an object (typically a hash) marked as a certain type. I never realized that you could change the type on the fly, but of course it makes sense given how Perl does objects. I can't think of any other language where you can change the run-time type of an object after you've created it. You can do something similar in JavaScript and Smalltalk. You can change add or change a method on an object. Something similar to your example (in JavaScript): var ufo = new Bird(); ufo.i_am_a(); ufo.i_am_a = Plane.i_am_a; ufo.i_am_a(); But in Perl it's cooler because you get all the methods of the new type at once. In JavaScript or Smalltalk you'd have to set them all one at a time, I think. Arc (a dialect of Lisp) has objects that are tagged objects, but I don't know if Arc really has the notion of a run-time type. Arc isn't actually finished yet, so it's anyone's guess. Arc is more like JavaScript in that methods are part of the hash, whereas in Perl methods are part of a package that has the name of the run-time type. Now as to why you'd want to do this, I don't know. Might be useful for adding methods to an instance on the fly. I've done that in JavaScript, but it might be awkward in Perl to keep the existing methods and add a new one. If you just changed the object's type on the fly it might be initialized properly - that is the contents of it's hash might not have all the right keys set. JD -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/spug-list/attachments/20060110/db69d31e/attachment.html From andrew at sweger.net Tue Jan 10 12:25:15 2006 From: andrew at sweger.net (Andrew Sweger) Date: Tue, 10 Jan 2006 12:25:15 -0800 (PST) Subject: SPUG: Unidentified Flying Objects In-Reply-To: Message-ID: On Tue, 10 Jan 2006, Fred Morris wrote: > So I am going to try to explain this, and then at the end there is a little > standalone Perl script which runs and demonstrates just how easy it is to > change the class of an object in midair using Perl. Way back in 1999, a mild mannered coworker demonstrated a script that would use the Perl class name as a kind of state attribute as it managed a huge pool of flying objects. My only response was, "That is so cool! And sick." Somehow it seems to defeat the purpose of the academic OO model. But that's just because I can't think of a practical example of where this technique would actually be helpful to understanding the solution to a problem. -- Andrew B. Sweger -- The great thing about multitasking is that several things can go wrong at once. From spud at spudzeppelin.com Tue Jan 10 13:07:01 2006 From: spud at spudzeppelin.com (Jeff Almeida) Date: Tue, 10 Jan 2006 15:07:01 -0600 Subject: SPUG: Unidentified Flying Objects In-Reply-To: References: Message-ID: <86EC5A85-E0FB-462C-94C9-205D0974AF0D@spudzeppelin.com> On Jan 10, 2006, at 2:25 PM, Andrew Sweger wrote: > Somehow it seems to defeat the purpose of the academic OO model. But > that's just because I can't think of a practical example of where this > technique would actually be helpful to understanding the solution to a > problem. Think about the classic textbook example for multiple inheritance: a flying boat is both a boat and an airplane. But really, it doesn't act like both of them at the same time... this way, it's a boat when it's a boat and it's and airplane when it's an airplane. Or, as a second suggestion, certain professional athletes might have two (or more!) sets of statistics, based on which sport they happened to be playing at the time: Bo Jackson, Deion Sanders, Michael Jordan, and Danny Ainge all leap to mind right away.... My main question is how you keep track of whether an object can change its base class -- do you add some attribute common to a superclass that includes all of the possible classes something could become, itemizing which ones it may become? Or, is this whole proposition just a loosely-camouflaged form of multiple inheritance that reorders the inheritance hierarchy on the fly? And how in the world did you get warmer weather today than we did? *grin* **************************************** Jeff D. Almeida * Corinth, TX spud at spudzeppelin.com **************************************** From charles.e.derykus at boeing.com Tue Jan 10 13:47:49 2006 From: charles.e.derykus at boeing.com (DeRykus, Charles E) Date: Tue, 10 Jan 2006 13:47:49 -0800 Subject: SPUG: Unidentified Flying Objects Message-ID: Beware re-blessers that forgot to clean their dirty laundry.though.. From perlobj: Although a constructor can in theory re-bless a referenced object currently belonging to another class, this is almost certainly going to get you into trouble. The new class is responsible for all cleanup later. The previous blessing is forgotten, as an object may belong to only one class at a time. (Although of course it's free to inherit methods from many classes.) If you find yourself having to do this, the parent class is probably misbehaving, though. The plain vanilla re-bless below for instance doesn't call Foo's DESTROY method -- only Bar's. package Foo; sub new { my $self= shift; bless {}, $self } sub zap { my($self,$newself)=@_; bless $self, $newself } DESTROY { print "cleaning up Foo..."; } package Bar; sub new { my $self= shift; bless {}, $self }; DESTROY { print "cleaning up Bar..."; } package main; my $foo = Foo->new("Bar"); $foo->zap("Bar"); hth, -- Charles DeRykus -----Original Message-----. From: JD Brennan [mailto:jazzdev at gmail.com] Sent: Tuesday, January 10, 2006 12:15 PM To: Fred Morris Cc: spug-list at pm.org Subject: Re: SPUG: Unidentified Flying Objects On 1/10/06, Fred Morris wrote: sub zap { my $self = shift; my $new_me = shift; print "ZAP!\n"; return bless $self, $new_me; Yeah, that's odd. Calling bless more than once. That is kinda cool. I don't think you can do that in Ruby. Perl is strange that way. An object is just a reference to an object (typically a hash) marked as a certain type. I never realized that you could change the type on the fly, but of course it makes sense given how Perl does objects. I can't think of any other language where you can change the run-time type of an object after you've created it. You can do something similar in JavaScript and Smalltalk. You can change add or change a method on an object. Something similar to your example (in JavaScript): var ufo = new Bird(); ufo.i_am_a(); ufo.i_am_a = Plane.i_am_a; ufo.i_am_a(); But in Perl it's cooler because you get all the methods of the new type at once. In JavaScript or Smalltalk you'd have to set them all one at a time, I think. Arc (a dialect of Lisp) has objects that are tagged objects, but I don't know if Arc really has the notion of a run-time type. Arc isn't actually finished yet, so it's anyone's guess. Arc is more like JavaScript in that methods are part of the hash, whereas in Perl methods are part of a package that has the name of the run-time type. Now as to why you'd want to do this, I don't know. Might be useful for adding methods to an instance on the fly. I've done that in JavaScript, but it might be awkward in Perl to keep the existing methods and add a new one. If you just changed the object's type on the fly it might be initialized properly - that is the contents of it's hash might not have all the right keys set. JD -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/spug-list/attachments/20060110/13e64476/attachment.html From uril at exchange.microsoft.com Tue Jan 10 20:09:19 2006 From: uril at exchange.microsoft.com (Uri London) Date: Tue, 10 Jan 2006 20:09:19 -0800 Subject: SPUG: Unidentified Flying Objects In-Reply-To: <86EC5A85-E0FB-462C-94C9-205D0974AF0D@spudzeppelin.com> Message-ID: In C++: You can somewhat hack it, but changing the __vptr (typically the first pointer in a class) of one object, to point to a different __vtable. -----Original Message----- From: spug-list-bounces at pm.org [mailto:spug-list-bounces at pm.org] On Behalf Of Jeff Almeida Sent: Tuesday, January 10, 2006 1:07 PM To: Andrew Sweger Cc: Fred Morris; spug-list at pm.org Subject: Re: SPUG: Unidentified Flying Objects On Jan 10, 2006, at 2:25 PM, Andrew Sweger wrote: > Somehow it seems to defeat the purpose of the academic OO model. But > that's just because I can't think of a practical example of where this > technique would actually be helpful to understanding the solution to a > problem. Think about the classic textbook example for multiple inheritance: a flying boat is both a boat and an airplane. But really, it doesn't act like both of them at the same time... this way, it's a boat when it's a boat and it's and airplane when it's an airplane. Or, as a second suggestion, certain professional athletes might have two (or more!) sets of statistics, based on which sport they happened to be playing at the time: Bo Jackson, Deion Sanders, Michael Jordan, and Danny Ainge all leap to mind right away.... My main question is how you keep track of whether an object can change its base class -- do you add some attribute common to a superclass that includes all of the possible classes something could become, itemizing which ones it may become? Or, is this whole proposition just a loosely-camouflaged form of multiple inheritance that reorders the inheritance hierarchy on the fly? And how in the world did you get warmer weather today than we did? *grin* **************************************** Jeff D. Almeida * Corinth, TX spud at spudzeppelin.com **************************************** _____________________________________________________________ Seattle Perl Users Group Mailing List POST TO: spug-list at pm.org SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list MEETINGS: 3rd Tuesdays, Location: Amazon.com Pac-Med WEB PAGE: http://seattleperl.org/ From m3047 at inwa.net Tue Jan 10 23:51:40 2006 From: m3047 at inwa.net (Fred Morris) Date: Tue, 10 Jan 2006 23:51:40 -0800 Subject: SPUG: Unidentified Flying Objects Message-ID: Thanks JD, Andrew, Jeff and Charles: Who'd'a thunk it? So, by the criterion that it's been thought of before, it's crazy, but I'm not. Thanks to all of you, and it's been an interesting little excursion. I'll give some more detail about the actual app, because it speaks to how crazy this is (or isn't). There are a small handful of patterns for this (web-based) application, and there are a small handful of base classes which all declare some standard "make it go" method which might be called ->handle-request(), and this method in turn invokes any number of methods in some predefined order which carry out the request. The base class defines default implementations of these methods and subclasses override them as needed (actually for one-offs they just provide callbacks; I am not a purist). One of these patterns looks like: web request stuff, parameter bomb checking, validation, access checking, some template fiddling, major lifting, some more template fiddling, and finally return it to the user. I don't mean to oversimplify. Let's call this the "edit" pattern. One of the (maybe the only) aberrational edit operations is to take ownership. At that point after what would otherwise be access checking we have by definition arrived at the same state of knowledge which we would have had by passively checking information which had been supplied in the request had we owned the object in the first place. In the web interface, the user was provided with a (read only) screen with an "edit" button. In the pattern, pretty much all of the heavy lifting from this point on, for taking ownership, is a no-op. So: do we send back some JavaScript template which immediately sends a more usual request to edit the object, or do we erect some scaffolding on the server side to accomplish the same thing.. or recognizing that we are where we want to be do we simply, somehow, turn one kind of request into another? Who knew that was possible? Well, obviously I didn't until maybe 48 hours ago. I know how I'd do it in Java (is this the third unspoken question: to know what rules one is breaking?), I'd have some sort of factory class managing (mangling?) an "item" class and a machinery class (subclassing the fabrication steps) which fabricated it. I'd swap the machinery out. (This is the subjective exercise: by doing so did I change the whole factory, or did I pick the item up and move it to a different line mid-fabrication? Does it matter?) You can turn that inside out or sideways (like Cat's Cradle) and accomplish the same thing. JD wrote: >You can do something similar in JavaScript and Smalltalk. >You can change add or change a method on an object. >Something similar to your example (in JavaScript): > >var ufo = new Bird(); >ufo.i_am_a(); >ufo.i_am_a = Plane.i_am_a; >ufo.i_am_a(); > Yah, this is the callback notion and of course this is the kind of thing the one-offs (which don't achieve full incarnation as subclasses) do.. very much like the example given. I suppose the existing implementation looks a lot like the "factory" described above, except that the factory (and its subclasses) are the machinery and there is no discrete item (it is embodied in the properties of the "factory"). That JavaScript example looks like you're taking the function definition (which is an object) and using it to replace a different one. Cool. This is how we would have done it in C, too, with some sort of struct containing the procedure pointers for the various state handlers. I liked it then, I like it now. I like state engines. ;-) Changing the handlers mid-operation is unconventional but hearkens to the concept of frames which is encountered in expert systems. I don't think this sort of problem is particularly new, I just don't think that it occurs often enough to rise above idiom and idiosyncracy to the kind of thing which a language goes out of its way to tackle (except, apparently, Perl.. although I think it's arguable that it goes out of its way to handle it). I suppose the best question would be: why not simply overwrite the handlers when you realize the situation has changed? I don't have a great answer for that, other than if you've done something once why do it again? Jeff Almeida wrote: >Think about the classic textbook example for multiple inheritance: a >flying boat >is both a boat and an airplane. But really, it doesn't act like both >of them at the >same time... this way, it's a boat when it's a boat and it's and >airplane when it's >an airplane. That is a textbook example, and maybe that is what Andrew was also thinking about. Actually Andrew doesn't say that, on re-reading. Now I'm confused. Well this seems like a textbook example. There is something about "academic" and "Perl" in the same sentence and I think he knows what I'm talking about. So, because he wasn't thinking about it, he was thinking about it... clear as mud? I was really coming at this particular case from the essential realization that there was a point where an object which I was considering to be one thing was in fact another in all but name... and this name was what was preventing it from carrying on with being what it was. Charles DeRykus wrote: >Beware re-blessers that forgot to clean their dirty laundry.... I have a name! :-) :-) Good point. Anything in my particular universe is going to change into a subclass of the same base class. The pattern is defined by the base class. I don't actually have destructors, although if they were defined by the base class my guess is that I'd be o.k. I am inclined to go with this rather sublime hack, and to document the crap out of it and erect some sort of cage around it so that things can only transmogrify into subclasses of the same base class. From sthoenna at efn.org Wed Jan 11 01:38:47 2006 From: sthoenna at efn.org (Yitzchak Scott-Thoennes) Date: Wed, 11 Jan 2006 01:38:47 -0800 Subject: SPUG: Unidentified Flying Objects In-Reply-To: References: Message-ID: <20060111093846.GB2532@efn.org> On Tue, Jan 10, 2006 at 10:26:20AM -0800, Fred Morris wrote: > sub zap { > > my $self = shift; > my $new_me = shift; > > print "ZAP!\n"; > > return bless $self, $new_me; > > } # &zap This is better written sub zap { my $new_me = $_[1]; print "ZAP!\n"; return bless $_[0], $new_me; } otherwise the overloaded flag won't be correctly set on the zapped object if zapping from an overloaded class to a non-overloaded class or vice versa. Even done this way, copies of the object/reference will be out of sync: $ perl use warnings; use strict; { package Foo; use overload q!""! => sub { "overloaded!" }; sub new { bless {} } } { package Bar; sub new { bless {} } } sub zap { bless $_[0], $_[1] } $a = $b = Foo::->new; zap($b, "Bar"); print "a: ", eval{"$a"} || "stringify croaked!", " b: $b\n"; $a = $b = Bar::->new; zap($b, "Foo"); print "a: ", eval{"$a"} || "stringify croaked!", " b: $b\n"; __END__ a: stringify croaked! b: Bar=HASH(0x47f060) a: Foo=HASH(0x4b89a0) b: overloaded! This happens because the overload flag is stored on the reference, not the referent, for efficiency, so only the copy of the reference passed to bless and any later copies of it are correctly overloaded. From david.s.patterson at usa.net Wed Jan 11 10:09:30 2006 From: david.s.patterson at usa.net (David S.Patterson) Date: Wed, 11 Jan 2006 10:09:30 -0800 Subject: SPUG: BSD Sockets and perl Message-ID: <935kakR8I7584S22.1137002970@cmsweb10.cms.usa.net> An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/spug-list/attachments/20060111/6819d641/attachment.html From james at banshee.com Wed Jan 11 10:58:00 2006 From: james at banshee.com (James Moore) Date: Wed, 11 Jan 2006 10:58:00 -0800 Subject: SPUG: BSD Sockets and perl In-Reply-To: <935kakR8I7584S22.1137002970@cmsweb10.cms.usa.net> Message-ID: <200601111857.k0BIvsch003334@server2.banshee.com> You're describing the normal way to use sockets, so giving pointers to examples would be tough - 90% of the example code for sockets would work just fine. Don't get hung up on the distinction between "clients" and "servers" - those concepts are higher-level abstractions that don't really mean much at the socket level. Once the connection is established you've got two peers speaking to each other, and designating one side the "server" may help you think about a problem but there's nothing going on to enforce that thought. - James From cmeyer at helvella.org Wed Jan 11 11:16:50 2006 From: cmeyer at helvella.org (Colin Meyer) Date: Wed, 11 Jan 2006 11:16:50 -0800 Subject: SPUG: BSD Sockets and perl In-Reply-To: <935kakR8I7584S22.1137002970@cmsweb10.cms.usa.net> References: <935kakR8I7584S22.1137002970@cmsweb10.cms.usa.net> Message-ID: <20060111191650.GA4833@funpox.helvella.org> On Wed, Jan 11, 2006 at 10:09:30AM -0800, David S.Patterson wrote: > > >

I have a > perl project that requires a client server with continuous two- > way communications.

... >

Does anyone have any example code for continuous two way > communication over sockets in perl (or C/C++) that they would be > willing to share?  Any other suggestions?

There's a few examples in the perlipc manpage ('perldoc perlipc', search for socket), and more in the Perl Cookbook. -Colin. From sthoenna at efn.org Wed Jan 11 11:23:55 2006 From: sthoenna at efn.org (Yitzchak Scott-Thoennes) Date: Wed, 11 Jan 2006 11:23:55 -0800 Subject: SPUG: Mailing list trailer Message-ID: <20060111192355.GA3708@efn.org> > _____________________________________________________________ > Seattle Perl Users Group Mailing List > POST TO: spug-list at pm.org > SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list > MEETINGS: 3rd Tuesdays, Location: Amazon.com Pac-Med > WEB PAGE: http://seattleperl.org/ The location should probably be removed from there. From andrew at sweger.net Wed Jan 11 12:08:37 2006 From: andrew at sweger.net (Andrew Sweger) Date: Wed, 11 Jan 2006 12:08:37 -0800 (PST) Subject: SPUG: Mailing list trailer In-Reply-To: <20060111192355.GA3708@efn.org> Message-ID: On Wed, 11 Jan 2006, Yitzchak Scott-Thoennes wrote: > > _____________________________________________________________ > > Seattle Perl Users Group Mailing List > > POST TO: spug-list at pm.org > > SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list > > MEETINGS: 3rd Tuesdays, Location: Amazon.com Pac-Med > > WEB PAGE: http://seattleperl.org/ > > The location should probably be removed from there. Done. -- Andrew B. Sweger -- The great thing about multitasking is that several things can go wrong at once. See? From david.s.patterson at usa.net Wed Jan 11 13:06:20 2006 From: david.s.patterson at usa.net (David S.Patterson) Date: Wed, 11 Jan 2006 13:06:20 -0800 Subject: SPUG: BSD Sockets and perl Message-ID: <249kakVgu7968S21.1137013580@cmsweb21.cms.usa.net> An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/spug-list/attachments/20060111/10421b55/attachment.html From schuh at farmdale.com Wed Jan 11 13:22:31 2006 From: schuh at farmdale.com (Mike Schuh) Date: Wed, 11 Jan 2006 13:22:31 -0800 (PST) Subject: SPUG: BSD Sockets and perl In-Reply-To: <249kakVgu7968S21.1137013580@cmsweb21.cms.usa.net> Message-ID: On Wed, 11 Jan 2006, David S.Patterson wrote: >So you're saying either the client or server can read or write to each >other, blocking or non-blocking, with the same basic functions once the >connection is established? "client" and "server" merely indicate who called whom. Think phone calls: the client calls the server but after that either may talk or both. Heck, neither could say anything - this could serve as an interesting way to monitor connectivity. -- Mike Schuh -- Seattle, Washington USA http://www.farmdale.com From mike206 at gmail.com Wed Jan 11 13:35:01 2006 From: mike206 at gmail.com (mike) Date: Wed, 11 Jan 2006 14:35:01 -0700 Subject: SPUG: BSD Sockets and perl In-Reply-To: References: <249kakVgu7968S21.1137013580@cmsweb21.cms.usa.net> Message-ID: the perl cookbook is very handy for this and should answer your questions and give all the examples you need. http://www.unix.org.ua/orelly/perl/cookbook/ch17_01.htm note the mispelling of 'oreilly' in the URL On 1/11/06, Mike Schuh wrote: > > On Wed, 11 Jan 2006, David S.Patterson wrote: > > >So you're saying either the client or server can read or write to each > >other, blocking or non-blocking, with the same basic functions once the > >connection is established? > > "client" and "server" merely indicate who called whom. Think phone calls: > the client calls the server but after that either may talk or both. > Heck, neither could say anything - this could serve as an interesting way > to monitor connectivity. > > -- > Mike Schuh -- Seattle, Washington USA > http://www.farmdale.com > > _____________________________________________________________ > Seattle Perl Users Group Mailing List > POST TO: spug-list at pm.org > SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list > MEETINGS: 3rd Tuesdays > WEB PAGE: http://seattleperl.org/ > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/spug-list/attachments/20060111/7a8045e0/attachment.html From m3047 at inwa.net Wed Jan 11 14:17:52 2006 From: m3047 at inwa.net (Fred Morris) Date: Wed, 11 Jan 2006 14:17:52 -0800 (PST) Subject: SPUG: client vs. server Re: BSD Sockets and perl In-Reply-To: References: Message-ID: Client and server do retain some conventional meaning in blocking situations, because the server is likely to block waiting for requests, and the client is likely to block waiting for replies. Of course if the server is capable of handling multiple requests simultaneously that changes things, and if the client is requesting stuff from multiple servers that changes things, and so forth. Remember: "blocking" means.. blocking! (Is this an appropriate time to mention UDP, and suggest they evaluate the nature of the communication in terms of reliability which is required as well as the reliability of the connection?) (Also, what about expect?) On Wed, 11 Jan 2006, Mike Schuh wrote: > On Wed, 11 Jan 2006, David S.Patterson wrote: > > >So you're saying either the client or server can read or write to each > >other, blocking or non-blocking, with the same basic functions once the > >connection is established? > > "client" and "server" merely indicate who called whom. Think phone calls: > the client calls the server but after that either may talk or both. > Heck, neither could say anything - this could serve as an interesting way > to monitor connectivity. -- Fred Morris http://www.inwa.net/~m3047/contact.html From cwilkes-spug at ladro.com Wed Jan 11 17:14:44 2006 From: cwilkes-spug at ladro.com (Chris Wilkes) Date: Wed, 11 Jan 2006 17:14:44 -0800 Subject: SPUG: Getting the current time perl snippet on TheDailyWTF Message-ID: <20060112011444.GC14691@chisq.ladro.com> Saw this in that website's RSS feed for today: http://thedailywtf.com/forums/56361/ShowPost.aspx Without many of the built-in date/time functions found in other languages, some Perl users can find themselves having to write some interesting code in order to get the results they want. Sure, it's pretty easy to reference the DateTime module, or a whole host of other modules to help with this, but who wants to use code that someone else invented? Some resort to fiddling with the number of seconds since epoch returned by the time() function. Others, such as Mike's predecessor, issue an operating system command to write the date out to text file, read the file back in, parse it, and use the result ... #write out date system("date >/tmp/the.date"); #read it back in open(THEDATE, ") { chop; @datevals = split(/ /,$_); } close(THEDATE); From uril at exchange.microsoft.com Thu Jan 12 01:27:47 2006 From: uril at exchange.microsoft.com (Uri London) Date: Thu, 12 Jan 2006 01:27:47 -0800 Subject: SPUG: Parsing (Windows) PE files in Perl Message-ID: Please forgive me if this is a trivial question - I'm just doing my very first steps in Perl. I need to extract some information from the headers of PE files (If you have left the Unix realm, PE files are Windows executables - DLL's, EXE's, SYS's etc. These files start with 'MZ'). The files have a binary structure. They starts with IMAGE_DOS_HEADER, which is concatenated with IMAGE_OS_HEADER, IMAGE_FILE_HEADER, and then bunch of different directories, with various offsets, depends on values on the previous headers. The headers contains information such as size (of various sections), bunch of attributes, version, check-sums, timestamps, offsets to other structures resources, offsets to tables, list of imports, list of exports, etc. etc. These structures and various definitions to magic values are all public and defined in C/C++ in winnt.h in the platform SDK. I'm not sure that Perl is the best choice for this task, but I'd like to try to do it in Perl, so I'd like to consult this alias about the best strategy. Is Perl the right language to parse binary files? Is anyone aware of an already existing package to does this job? Assuming a package doesn't exist, please help with some novice questions: - How to open a file in a binary mode? - How do I read blobs from a file? - How to unpack a binary structure? - If I need to, can I seek (forward, backward), or another mean to have random access. Does Perl support memory mapping? Thanks a lot. u. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/spug-list/attachments/20060112/ece977c3/attachment-0001.html From jerry.gay at gmail.com Thu Jan 12 06:56:45 2006 From: jerry.gay at gmail.com (jerry gay) Date: Thu, 12 Jan 2006 06:56:45 -0800 Subject: SPUG: Parsing (Windows) PE files in Perl In-Reply-To: References: Message-ID: <1d9a3f400601120656i4f9b8f3eucd8383e7d74b0668@mail.gmail.com> On 1/12/06, Uri London wrote: > Please forgive me if this is a trivial question ? I'm just doing my very > first steps in Perl. > welcome! > I need to extract some information from the headers of PE files (If you have > left the Unix realm, PE files are Windows executables ? DLL's, EXE's, SYS's > etc. These files start with 'MZ'). > > The files have a binary structure. They starts with IMAGE_DOS_HEADER, which > is concatenated with IMAGE_OS_HEADER, IMAGE_FILE_HEADER, and then bunch of > different directories, with various offsets, depends on values on the > previous headers. The headers contains information such as size (of various > sections), bunch of attributes, version, check-sums, timestamps, offsets to > other structures resources, offsets to tables, list of imports, list of > exports, etc. etc. > > These structures and various definitions to magic values are all public and > defined in C/C++ in winnt.h in the platform SDK. > > I'm not sure that Perl is the best choice for this task, but I'd like to try > to do it in Perl, so I'd like to consult this alias about the best strategy. > > Is Perl the right language to parse binary files? > YES! > Is anyone aware of an already existing package to does this job? > no, i'm not. but the best place to look is CPAN (http://search.cpan.org/) > Assuming a package doesn't exist, please help with some novice questions: > > - How to open a file in a binary mode? see 'perldoc -f binmode' it'll go something like: my $file = 'foo.dll'; open(local *PE, '>', my $file) or die qq{can't open $file: $!}; binmode 1; # read from the file... close *PE; # remember to close it when you're done > - How do I read blobs from a file? > see 'perldoc -f read' > - How to unpack a binary structure? > see 'perldoc -f unpack', and related, 'perldoc -f pack'. there's too much to go into here, but google is your friend. something like 'perl pack tutorial' should provide helpful. > - If I need to, can I seek (forward, backward), or another mean to > have random access. Does Perl support memory mapping? > you can use 'seek' and 'tell' to move around in the file, and find out where you are. my $curpos; my $newpos = 2; seek *PE, $newpos, 0 or die qq{can't move to position $newpos in file $file: $!}; $curpos = tell *PE; print qq{i'm at position $curpos in file $file}; for memory mapping, there is a module you can use to help: see Win32::MMF (http://search.cpan.org/~roger/Win32-MMF-0.09e/) good luck! ~jerry BTW i use the qq{} quoting construct instead of single- or double-quotes so i don't have to worry about escaping them. you can find more by reading the 'Quote and Quote-Like Operators' section 'perldoc perlop'. From david.dyck at fluke.com Thu Jan 12 07:12:27 2006 From: david.dyck at fluke.com (David Dyck) Date: Thu, 12 Jan 2006 07:12:27 -0800 (PST) Subject: SPUG: Parsing (Windows) PE files in Perl In-Reply-To: References: Message-ID: On Thu, 12 Jan 2006 at 01:27 -0800, Uri London Assuming a package doesn't exist, please help with some novice questions: ... > - How to unpack a binary structure? I'd recomend this useful tool on CPAN: Convert::Binary::C - Binary Data Conversion using C Types and it comes with extensive documenation. DESCRIPTION Convert::Binary::C is a preprocessor and parser for C type definitions. It is highly configurable and should support arbitrarily complex data structures. Its object-oriented interface has "pack" and "unpack" methods that act as replacements for Perl's "pack" and "unpack" and allow to use the C types instead of a string representation of the data structure for conversion of binary data from and to Perl's complex data structures. Actually, what Convert::Binary::C does is not very different from what a C compiler does, just that it doesn't compile the source code into an object file or executable, but only parses the code and allows Perl to use the enumerations, structs, unions and typedefs that have been defined within your C source for binary data conversion, similar to Perl's "pack" and "unpack". Beyond that, the module offers a lot of convenience methods to retrieve information about the C types that have been parsed. -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: ATT1463384.txt Url: http://mail.pm.org/pipermail/spug-list/attachments/20060112/cbc31d01/ATT1463384.txt From james at banshee.com Thu Jan 12 11:31:07 2006 From: james at banshee.com (James Moore) Date: Thu, 12 Jan 2006 11:31:07 -0800 Subject: SPUG: Parsing (Windows) PE files in Perl In-Reply-To: <1d9a3f400601120656i4f9b8f3eucd8383e7d74b0668@mail.gmail.com> Message-ID: <200601121931.k0CJV1II021887@server2.banshee.com> Much as I like perl, it's not the first tool I reach for when I'm doing things like parsing executable files. Usually you've got a bunch of header files, usually in C, it's simpler just to play in C-land. Much of the strength of perl doesn't apply to mucking around with binaries. Sure, it can do it, but since you tend to be doing lots of things that look like pointer arithmetic, why not just use C? - James From jobs-noreply at seattleperl.org Thu Jan 12 14:02:47 2006 From: jobs-noreply at seattleperl.org (SPUG Jobs) Date: Thu, 12 Jan 2006 14:02:47 -0800 (PST) Subject: SPUG: JOB: 4 Perl jobs at local e-commerce companies Message-ID: The Lincoln Bay agency is currently looking for Perl developers to place at two different companies, in four different positions. Required Skill-Set Perl application development (not scripting), some PHP, and MySQL would be nice Contract or Perm There are two permanent needs (one at each of the two companies), and two contract opportunities. Contract Duration 3+ months, possibility of converting to permanent Availability of Stock and Bonus Depends on experience. Recruiter or Directly with Company Through recruiting firm W-2 vs 1099 Contracts will be on W-2 basis Physical Location Both companies are on West side of water. One is slightly south of downtown, the other is north. Telecommuting Possible Depends, negotiable Company product or service e-commerce Have anyone interested call me for more info. Thanks for the help, I'm looking forward to working with you. Travis J. Winegardner Lincoln Bay | Recruiter travisw at lincolnbay.com 1000 2nd Ave, Ste 1900, Seattle (p) 206.438.5702 (f) 206.438.5711 From sthoenna at efn.org Thu Jan 12 18:55:29 2006 From: sthoenna at efn.org (Yitzchak Scott-Thoennes) Date: Thu, 12 Jan 2006 18:55:29 -0800 Subject: SPUG: Parsing (Windows) PE files in Perl In-Reply-To: <1d9a3f400601120656i4f9b8f3eucd8383e7d74b0668@mail.gmail.com> References: <1d9a3f400601120656i4f9b8f3eucd8383e7d74b0668@mail.gmail.com> Message-ID: <20060113025528.GA2236@efn.org> On Thu, Jan 12, 2006 at 06:56:45AM -0800, jerry gay wrote: > On 1/12/06, Uri London wrote: > > > Assuming a package doesn't exist, please help with some novice questions: > > > > - How to open a file in a binary mode? > see 'perldoc -f binmode' > it'll go something like: > > my $file = 'foo.dll'; > open(local *PE, '>', my $file) > or die qq{can't open $file: $!}; > binmode 1; Are there versions of perl that support 3-arg open but not lexical filehandles? There are a couple of errors there; I'd make that: my $file = 'foo.dll'; open( my $pe, '>', $file ) or die "Can't open $file: $!"; binmode $pe; From jerry.gay at gmail.com Fri Jan 13 09:00:40 2006 From: jerry.gay at gmail.com (jerry gay) Date: Fri, 13 Jan 2006 09:00:40 -0800 Subject: SPUG: Parsing (Windows) PE files in Perl In-Reply-To: References: <1d9a3f400601120656i4f9b8f3eucd8383e7d74b0668@mail.gmail.com> Message-ID: <1d9a3f400601130900n51ee1a91g7990dbac460bb26c@mail.gmail.com> On 1/13/06, David Dyck wrote: > > On Thu, 12 Jan 2006 at 06:56 -0800, jerry gay wrote: > > > it'll go something like: > > > > my $file = 'foo.dll'; > > open(local *PE, '>', my $file) > > or die qq{can't open $file: $!}; > > binmode 1; > > > > # read from the file... > > > > close *PE; # remember to close it when you're done > > > You comment about reading from the file, but doesn't > the open flag '>' WRITE to the file? > that's the danger of coding perl at 6:56am. my $file = 'foo.dll'; open(local *PE, '<', my $file) or die qq{can't open $file: $!}; binmode *PE; should work much better for reading a file. on another note, if yitzchak's scalar ref-to-filehandle syntax is preferred, use that. it works just as well. ~jerry From andrew at sweger.net Fri Jan 13 10:04:46 2006 From: andrew at sweger.net (Andrew Sweger) Date: Fri, 13 Jan 2006 10:04:46 -0800 (PST) Subject: SPUG: Parsing (Windows) PE files in Perl In-Reply-To: <1d9a3f400601130900n51ee1a91g7990dbac460bb26c@mail.gmail.com> Message-ID: On Fri, 13 Jan 2006, jerry gay wrote: > that's the danger of coding perl at 6:56am. > > my $file = 'foo.dll'; > open(local *PE, '<', my $file) ^^ ?? > or die qq{can't open $file: $!}; > binmode *PE; > > should work much better for reading a file. -- Andrew B. Sweger -- The great thing about multitasking is that several things can go wrong at once. From csimmons at whitepages.com Mon Jan 16 14:39:59 2006 From: csimmons at whitepages.com (Craig Simmons) Date: Mon, 16 Jan 2006 14:39:59 -0800 Subject: SPUG: January SPUG Meeting: 01/17/2006 at Whitepages.com Message-ID: All - Just a reminder that this month's SPUG meeting will take place at Whitepages.com's offices in downtown Seattle tomorrow night, January 17th, at 6:30 PM. Tomorrow's meeting will feature talks by Mike Schuh and Dave Olszewski on Perl/Tk and Perl/Gtk respectively. Whitepages.com is located on the 16th floor of the Rainier Square Tower (1301 5th Avenue, Seattle) which is across from the 5th Avenue Theater. If you need directions, visit " http://www.whitepagesinc.com/locations " for a quick primer on how to reach us from various locations across Puget Sound. There are plenty of locations to park in the area, including on the street. If you're looking for off-street parking, you can park in the Rainier Square garage which has an entrance on Union St. After 6PM, the building management restricts access to most floors. I'm trying to take care of this, but if I'm unsuccessful, we'll station someone on the 1st floor near the elevator bank and 5th Avenue entrance to let people in. Worst case scenario, give me a call on my cell phone (206-579-7113) and I'll run down to let you in. Finally, we have a broad assortment of free sodas, fruit drinks, teas, and coffee, and also have some snacks. You definitely won't dehydrate here. We look forward to seeing you! Craig Simmons Director of Product Development W H I T E P A G E S .C O M | I N C p: 206.973.5165 | f: 206.621.1375 csimmons at whitepages.com www.whitepagesinc.com The information contained in this message may be privileged, confidential, and protected from disclosure. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution, or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by replying to the message and deleting it from your computer. From bill at celestial.com Mon Jan 16 15:02:49 2006 From: bill at celestial.com (Bill Campbell) Date: Mon, 16 Jan 2006 15:02:49 -0800 Subject: SPUG: January SPUG Meeting: 01/17/2006 at Whitepages.com In-Reply-To: References: Message-ID: <20060116230249.GB34561@alexis.mi.celestial.com> On Mon, Jan 16, 2006, Craig Simmons wrote: >All - > >Just a reminder that this month's SPUG meeting will take place at >Whitepages.com's offices in downtown Seattle tomorrow night, January >17th, at 6:30 PM. Anybody on the east side want to meet at the Mercer Island Park and Ride to carpool over? Bill -- INTERNET: bill at Celestial.COM Bill Campbell; Celestial Systems, Inc. URL: http://www.celestial.com/ PO Box 820; 6641 E. Mercer Way FAX: (206) 232-9186 Mercer Island, WA 98040-0820; (206) 236-1676 Just because you do not take an interest in politics doesn't mean politics won't take an interest in you. -- Pericles From dblanchard at gmail.com Mon Jan 16 15:55:16 2006 From: dblanchard at gmail.com (Duane Blanchard) Date: Mon, 16 Jan 2006 15:55:16 -0800 Subject: SPUG: January SPUG Meeting: 01/17/2006 at Whitepages.com In-Reply-To: <20060116230249.GB34561@alexis.mi.celestial.com> References: <20060116230249.GB34561@alexis.mi.celestial.com> Message-ID: Hello all, Thanks for announcing the meeting, I've been swamped today with other things. It seems that the time is passed for any suggestions on a later time. Let's bring this up at the meeting if anyone thinks 6:30 is too early still (we'll wait till any late-comers have arrived). As a reminder, street parking opens at 6:00 p.m. and Pacific Place is between 3$ and 5$ after 5pm. Mike will give a preview of a future talk on Perl-Tk. I was told that Dave Olszewski will also provide some structured content. I'd like to discuss a way to automatically synchronize my bookmarks/favorites between computers either over IP or SneakerNet (e.g. when I plug my USB drive in, it is checked for updates upon connecting. I hope some others will have some questions or didyaknows for us also. In answer to Bill's question about carpooling, I work in BV, and live in Seattle. I'll happily give you a ride from the P&R to WhitePages, but you would need to find a ride back. Perhaps someone else lives in BV and works in Seattle. Anyone? Does anyone know the status of a projector? Thanks all. D -- Duane Blanchard 206.280.1263 There are 10 kinds of people in the world; those who know binary and those who don't. From andrew at sweger.net Mon Jan 16 18:33:48 2006 From: andrew at sweger.net (Andrew Sweger) Date: Mon, 16 Jan 2006 18:33:48 -0800 (PST) Subject: SPUG: January SPUG Meeting: 01/17/2006 at Whitepages.com In-Reply-To: Message-ID: On Mon, 16 Jan 2006, Duane Blanchard wrote: > Does anyone know the status of a projector? If the meeting is in Whitepages.com's conference room, there's a built-in one there (last time I was there many months ago). -- Andrew B. Sweger -- The great thing about multitasking is that several things can go wrong at once. From andrew at sweger.net Tue Jan 17 10:07:02 2006 From: andrew at sweger.net (Andrew Sweger) Date: Tue, 17 Jan 2006 10:07:02 -0800 (PST) Subject: SPUG: SVK & Subversion (tonight?) Message-ID: If I'm able to make it to the meeting and we run out of time for more Perlish things (and if I get a couple things installed on my laptop), I'll offer to demonstrate how to get started using SVK. SVK is a compelling way to work with various source code repositories. I will focus on Subversion (SVN) as the backend repository. (I've been using SVK for about eight months and just love the trouble it keeps me out of.) P.S. - SVK is written in Perl (if that matters). -- Andrew B. Sweger -- The great thing about multitasking is that several things can go wrong at once. From lmzaldivar at gmail.com Tue Jan 17 13:19:22 2006 From: lmzaldivar at gmail.com (luis medrano) Date: Tue, 17 Jan 2006 13:19:22 -0800 Subject: SPUG: regular expressions Message-ID: <50aeae6f0601171319h19ba0791k3922618aec409e28@mail.gmail.com> List, I have a problem I need to modified some strings with the first character of each word with a upper case for example: from: perl is number one to Perl Is Number One my question is how can I do this using regular expressions? Thanks, Luis From jmates at sial.org Tue Jan 17 13:26:00 2006 From: jmates at sial.org (Jeremy Mates) Date: Tue, 17 Jan 2006 13:26:00 -0800 Subject: SPUG: regular expressions In-Reply-To: <50aeae6f0601171319h19ba0791k3922618aec409e28@mail.gmail.com> References: <50aeae6f0601171319h19ba0791k3922618aec409e28@mail.gmail.com> Message-ID: <20060117212600.GA6029@neamh.sial.org> * luis medrano > perl is number one > to > Perl Is Number One Quick, dirty, and possibly missing all sorts of edge cases: echo test ing | perl -pe 's/\b(\w)/\U$1/g' Depending on what you are doing, also consider {case => title} or {case => highlight} of the nifty Text::Autoformat module. http://search.cpan.org/perldoc/Text::Autoformat From stephen.menton at cingular.com Tue Jan 17 13:37:56 2006 From: stephen.menton at cingular.com (Menton, Stephen) Date: Tue, 17 Jan 2006 13:37:56 -0800 Subject: SPUG: regular expressions Message-ID: I'd opt for 's/(\w+)/\u$1/g' if you want to leave the remaining characters untouched, 's/(\w+)/\u\L$1/g' if you want to force all other letters to be lowercase. steve -----Original Message----- From: spug-list-bounces at pm.org [mailto:spug-list-bounces at pm.org] On Behalf Of luis medrano Sent: Tuesday, January 17, 2006 13:19 To: spug-list at pm.org Subject: SPUG: regular expressions List, I have a problem I need to modified some strings with the first character of each word with a upper case for example: from: perl is number one to Perl Is Number One my question is how can I do this using regular expressions? Thanks, Luis _____________________________________________________________ Seattle Perl Users Group Mailing List POST TO: spug-list at pm.org SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list MEETINGS: 3rd Tuesdays WEB PAGE: http://seattleperl.org/ From rrue at fhcrc.org Tue Jan 17 14:07:14 2006 From: rrue at fhcrc.org (Randy Rue) Date: Tue, 17 Jan 2006 14:07:14 -0800 Subject: SPUG: regular expressions In-Reply-To: <20060117212600.GA6029@neamh.sial.org> References: <50aeae6f0601171319h19ba0791k3922618aec409e28@mail.gmail.com> <20060117212600.GA6029@neamh.sial.org> Message-ID: <43CD6A92.6040404@fhcrc.org> Bear with me for a newbie question, I'm right at the second regex chapeter in Learning Pearl and this question caught my attention: What does the (\w) in the pattern do to the \b word separator? I thought it might give whitespace as the word delimiter (and so keep words like "that's" as a single word) but the output still comes out as "That'S." How else could I treat contractions? Randy Rue Jeremy Mates wrote: > * luis medrano > >>perl is number one >>to >>Perl Is Number One > > > Quick, dirty, and possibly missing all sorts of edge cases: > > echo test ing | perl -pe 's/\b(\w)/\U$1/g' > > Depending on what you are doing, also consider {case => title} or {case > => highlight} of the nifty Text::Autoformat module. > > http://search.cpan.org/perldoc/Text::Autoformat > > _____________________________________________________________ > Seattle Perl Users Group Mailing List > POST TO: spug-list at pm.org > SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list > MEETINGS: 3rd Tuesdays > WEB PAGE: http://seattleperl.org/ -- Randall Rue System Administrator IT, Server Operations Fred Hutchinson Cancer Research Center 1100 Fairview Ave N #J4-414 Seattle, WA 98109-1024 USA (206) 667-3662 FAX (206) 667-7733 From sthoenna at efn.org Tue Jan 17 14:14:24 2006 From: sthoenna at efn.org (Yitzchak Scott-Thoennes) Date: Tue, 17 Jan 2006 14:14:24 -0800 Subject: SPUG: regular expressions In-Reply-To: <43CD6A92.6040404@fhcrc.org> References: <50aeae6f0601171319h19ba0791k3922618aec409e28@mail.gmail.com> <20060117212600.GA6029@neamh.sial.org> <43CD6A92.6040404@fhcrc.org> Message-ID: <20060117221423.GD3804@efn.org> On Tue, Jan 17, 2006 at 02:07:14PM -0800, Randy Rue wrote: > Bear with me for a newbie question, I'm right at the second regex > chapeter in Learning Pearl and this question caught my attention: > > What does the (\w) in the pattern do to the \b word separator? I thought > it might give whitespace as the word delimiter (and so keep words like > "that's" as a single word) but the output still comes out as "That'S." > > How else could I treat contractions? Whitespace as word delimiter doesn't work if you have 'quoted text'. Contractions are messy, something like: s/\b(? References: <50aeae6f0601171319h19ba0791k3922618aec409e28@mail.gmail.com> <20060117212600.GA6029@neamh.sial.org> <43CD6A92.6040404@fhcrc.org> Message-ID: \b is a zero-width assertion, meaning that it doesn't consume anything. It matches between what \W\w or \w\W would match. \w ("word") is not quite the opposite of \S ("not space"), due to punctuation, etc. Contrast these: echo "testing's tricky" | perl -pe 's/((?:^|\W)\w)/\U$1/g' echo "testing's tricky" | perl -pe 's/((?:^|\s)\S)/\U$1/g' -- Fred Morris On Tue, 17 Jan 2006, Randy Rue wrote: > What does the (\w) in the pattern do to the \b word separator? I thought > it might give whitespace as the word delimiter (and so keep words like > "that's" as a single word) but the output still comes out as "That'S." > > How else could I treat contractions? > > Randy Rue > > Jeremy Mates wrote: > > * luis medrano > > > >>perl is number one > >>to > >>Perl Is Number One > > > > > > Quick, dirty, and possibly missing all sorts of edge cases: > > > > echo test ing | perl -pe 's/\b(\w)/\U$1/g' > > From kenslinux at shaw.ca Tue Jan 17 14:31:46 2006 From: kenslinux at shaw.ca (Ken Clarke) Date: Tue, 17 Jan 2006 14:31:46 -0800 Subject: SPUG: regular expressions References: <50aeae6f0601171319h19ba0791k3922618aec409e28@mail.gmail.com> <20060117212600.GA6029@neamh.sial.org> <43CD6A92.6040404@fhcrc.org> Message-ID: <001601c61bb5$cd43a1f0$1000a8c0@kens> To identify the beginning of a word, match on the beginning of the string or a space character, followed by a letter. Also might as well only match on a lower case letter since that's all you want to change. $sentence =~ s/(^|\s)([a-z])/$1\U$2/g; ----- Original Message ----- From: "Randy Rue" To: Sent: Tuesday, January 17, 2006 2:07 PM Subject: Re: SPUG: regular expressions > Bear with me for a newbie question, I'm right at the second regex > chapeter in Learning Pearl and this question caught my attention: > > What does the (\w) in the pattern do to the \b word separator? I thought > it might give whitespace as the word delimiter (and so keep words like > "that's" as a single word) but the output still comes out as "That'S." > > How else could I treat contractions? > > Randy Rue > > Jeremy Mates wrote: >> * luis medrano >> >>>perl is number one >>>to >>>Perl Is Number One >> >> >> Quick, dirty, and possibly missing all sorts of edge cases: >> >> echo test ing | perl -pe 's/\b(\w)/\U$1/g' >> >> Depending on what you are doing, also consider {case => title} or {case >> => highlight} of the nifty Text::Autoformat module. >> >> http://search.cpan.org/perldoc/Text::Autoformat >> >> _____________________________________________________________ >> Seattle Perl Users Group Mailing List >> POST TO: spug-list at pm.org >> SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list >> MEETINGS: 3rd Tuesdays >> WEB PAGE: http://seattleperl.org/ > > -- > Randall Rue > System Administrator > IT, Server Operations > Fred Hutchinson Cancer Research Center > 1100 Fairview Ave N #J4-414 > Seattle, WA 98109-1024 > USA > (206) 667-3662 > FAX (206) 667-7733 > _____________________________________________________________ > Seattle Perl Users Group Mailing List > POST TO: spug-list at pm.org > SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list > MEETINGS: 3rd Tuesdays > WEB PAGE: http://seattleperl.org/ From james at banshee.com Tue Jan 17 16:10:27 2006 From: james at banshee.com (James Moore) Date: Tue, 17 Jan 2006 16:10:27 -0800 Subject: SPUG: CSV module that can handle multi-line entries? Message-ID: <200601180010.k0I0AIjQ021325@server2.banshee.com> I'm reading Outlook contact books, in what Outlook thinks of as CSV. They look like: "foo","this entry spans two lines"" and has an embedded quote",bar,snark Anyone know of a module that does this? All the CSV parsing I'm finding breaks with multiline quoted entries. - James From sthoenna at efn.org Tue Jan 17 22:03:05 2006 From: sthoenna at efn.org (Yitzchak Scott-Thoennes) Date: Tue, 17 Jan 2006 22:03:05 -0800 Subject: SPUG: CSV module that can handle multi-line entries? In-Reply-To: <200601180010.k0I0AIjQ021325@server2.banshee.com> References: <200601180010.k0I0AIjQ021325@server2.banshee.com> Message-ID: <20060118060305.GA2040@efn.org> On Tue, Jan 17, 2006 at 04:10:27PM -0800, James Moore wrote: > I'm reading Outlook contact books, in what Outlook thinks of as CSV. They > look like: > > "foo","this > entry spans two lines"" and has an embedded quote",bar,snark > > Anyone know of a module that does this? All the CSV parsing I'm finding > breaks with multiline quoted entries. I think Text::CSV_XS may do that. From benb at speakeasy.net Wed Jan 18 12:40:04 2006 From: benb at speakeasy.net (BenRifkah Burnett) Date: Wed, 18 Jan 2006 20:40:04 -0000 Subject: SPUG: Looking for HB that I met at the meeting last night Message-ID: <6.2.1.2.0.20060218124026.02b6b040@mail.speakeasy.net> Hey All, Thanks for the great presentations at the meeting last night. I met a gentleman named HB (could have been HP?) working with IMDb and was hoping to talk more after the meeting, but he had to leave early. If you're lurking out there please contact me. Thanks, -- Ben Burnett From moonbeam at catmanor.com Wed Jan 18 16:36:20 2006 From: moonbeam at catmanor.com (William Julien) Date: Wed, 18 Jan 2006 16:36:20 -0800 Subject: SPUG: CSV module that can handle multi-line entries? In-Reply-To: <200601180010.k0I0AIjQ021325@server2.banshee.com> References: <200601180010.k0I0AIjQ021325@server2.banshee.com> Message-ID: <57534616-66CC-471F-A147-8400DC31109B@catmanor.com> Try this... #!/usr/bin/perl -w # $text= ',A,cool "cat",A B,"A,B","A,""B"","A,\""B","A,\\\ \""B",,B,"foo","this entry spans two lines"" and has an embedded quote",bar,snark'; print "Original text\n\n",$text . "\n\n"; @fields = (); push(@fields, defined($+)?scalar($_=$+,$_ =~ s/""/"/g,$_):undef) while $text =~ m{ "([^\"]*(?:\"\"[^\"]*)*)",? ## standard string, w/ possible comma | ([^,]+),? ## anything else, w/ possible comma | , ## lone comma }gx; ## final empty field for trailing comma push(@fields, undef) if substr($text, -1, 1) eq ','; print "csv deliminated text\n\n"; printf "%6s%12s\n","field","data\n"; for ($i = $[; $i <= $#fields; $i++) { printf "%6s %12s", $i . " |" , (defined($fields[$i])?$fields[$i]:"undefined") . "|\n"; } On Jan 17, 2006, at 4:10 PM, James Moore wrote: > "foo","this > entry spans two lines"" and has an embedded quote",bar,snark From andrew at sweger.net Wed Jan 18 17:02:31 2006 From: andrew at sweger.net (Andrew Sweger) Date: Wed, 18 Jan 2006 17:02:31 -0800 (PST) Subject: SPUG: more love for SVK Message-ID: I gave a short (very short and fast) review of using SVK for source code management at the meeting last night. I just discovered a very handy trick that SVK knows: auto-merging If you create a branch, e.g., svk cp $SVN/trunk $SVN/branches/newfeature ...time passes as you work on newfeature... Later, you, cd newfeature-working-dir svk pull svk merge -a $SVN/trunk svk up will bring you up-to-date with the trunk without searching the logs for revision number ranges. Later, when you're ready to merge your branch to the trunk, svk co $SVN/trunk cd trunk svk merge -a $SVN/branches/newfeature Whoa. Niiiiice. The SVKBook is a little behind development (imagine that!). Of course, it's not as simple as that in reality. You still need discipline and policies for collaborators. But my goodness, does that ever take out one of the big headaches of merging. Oh, and conflicts: SVK will prompt you file-by-file if you like to ask how you want to handle conflicts (and even offers to show a diff). There's also a "successor" to SVK called SVL. It's a peer-to-peer revision manager that helps people work as a group with each using an isolated repository. It even works over Zeroconf (aka Apple Computer's Bonjour, nee Rendezvous) with auto-discovery of nearby repositories. Scary stuff. There was a demo at last year's OSCON in Portland (Leon Brocard & Artur Bergman). -- Andrew B. Sweger -- The great thing about multitasking is that several things can go wrong at once. From cxreg at pobox.com Wed Jan 18 22:25:25 2006 From: cxreg at pobox.com (Dave O) Date: Thu, 19 Jan 2006 00:25:25 -0600 (CST) Subject: SPUG: CSV module that can handle multi-line entries? Message-ID: On Tue Jan 17 22:03:05 PST 2006, Yitzchak Scott-Thoennes wrote: > On Tue, Jan 17, 2006 at 04:10:27PM -0800, James Moore wrote: > > I'm reading Outlook contact books, in what Outlook thinks of as CSV. They > > look like: > > > > "foo","this > > entry spans two lines"" and has an embedded quote",bar,snark > > > > Anyone know of a module that does this? All the CSV parsing I'm finding > > breaks with multiline quoted entries. > > I think Text::CSV_XS may do that. I can confirm that this is the case, provided you pass the binary => 1 option to new(). Quoth the POD: binary If this attribute is TRUE, you may use binary characters in quoted fields, including line feeds, carriage returns and NUL bytes. (The latter must be escaped as ""0".) By default this feature is off. and an example: perl -MData::Dumper -MText::CSV_XS -e ' my $csv = Text::CSV_XS->new({binary=>1}); $csv->parse(qq^"foo","bar\nbaz",biff^); print Dumper [$csv->fields]' $VAR1 = [ 'foo', 'bar baz', 'biff' ]; Dave From sthoenna at efn.org Thu Jan 19 03:26:39 2006 From: sthoenna at efn.org (Yitzchak Scott-Thoennes) Date: Thu, 19 Jan 2006 03:26:39 -0800 Subject: SPUG: CSV module that can handle multi-line entries? In-Reply-To: <20060118060305.GA2040@efn.org> References: <200601180010.k0I0AIjQ021325@server2.banshee.com> <20060118060305.GA2040@efn.org> Message-ID: <20060119112639.GB3496@efn.org> On Tue, Jan 17, 2006 at 10:03:05PM -0800, Yitzchak Scott-Thoennes wrote: > On Tue, Jan 17, 2006 at 04:10:27PM -0800, James Moore wrote: > > I'm reading Outlook contact books, in what Outlook thinks of as CSV. They > > look like: > > > > "foo","this > > entry spans two lines"" and has an embedded quote",bar,snark > > > > Anyone know of a module that does this? All the CSV parsing I'm finding > > breaks with multiline quoted entries. > > I think Text::CSV_XS may do that. Sorry, it was Text::xSV I was thinking of. From andrew at seattleperl.org Fri Jan 20 09:43:05 2006 From: andrew at seattleperl.org (Andrew Sweger) Date: Fri, 20 Jan 2006 09:43:05 -0800 (PST) Subject: SPUG: SPUG volunteer coordination mailing list Message-ID: I have created (well, actually David Cross created) a mailing list for SPUG activity coordination. This is to help support the distributed nature of our volunteer efforts without cluttering this list with administrivia. The list is publicly archived and anyone is welcome to subscribe. Currently, only subscribers may post to the list (but I suspect this will need to change at some point). To subscribe, please go to the following link. http://mail.pm.org/mailman/listinfo/spug-admin Thank you. Ob-Perlish: David Golden has published his slides[1] for his Inside-Out Objects talk at the recent Perl Seminar New York. Things have advanced even more since Damian Conway's Perl Best Practices book; my first practical introduction to the concept. I talked to David about visiting Seattle sometime this year to give his presentation. He's itching for a PNW visit (perhaps to coincide with OSCON '06). Keep your fingers crossed. [1] - http://dagolden.com/talks/20060117_whats_all_the_fuss.pdf -- Andrew B. Sweger | P.O. Box 33147 President | Seattle WA 98133 Seattle Perl Users Group | (206) 219-7119 andrew{at}seattleperl.org | http://seattleperl.org/ From schieb at centurytel.net Fri Jan 20 23:06:07 2006 From: schieb at centurytel.net (Islandman) Date: Fri, 20 Jan 2006 23:06:07 -0800 Subject: SPUG: PERL technical interview Message-ID: <200601210706.k0L768q6025389@msa1-gh.centurytel.net> I have some job interviews coming up, one in PERL where I'm to do the "code this on the fly on the whiteboard" exercise. I've worked in PERL quite a bit over the years but during the last 2 years have had my mind warped by .NET work and frankly feel awfully rusty for such an instant recall exercise. What would you recommend for a quick cram to try to be as ready as possible for such an interview? Thanks, -Brian From spug at i4031.net Sat Jan 21 03:49:20 2006 From: spug at i4031.net (David Robins) Date: Sat, 21 Jan 2006 05:49:20 -0600 Subject: SPUG: PERL technical interview In-Reply-To: <200601210706.k0L768q6025389@msa1-gh.centurytel.net> References: <200601210706.k0L768q6025389@msa1-gh.centurytel.net> Message-ID: <200601210549.20829.spug@i4031.net> On Saturday January 21, 2006 01:06, Islandman wrote: > I have some job interviews coming up, one in PERL where I'm to do the "code > this on the fly on the whiteboard" exercise. I've worked in PERL quite a bit > over the years but during the last 2 years have had my mind warped by .NET > work and frankly feel awfully rusty for such an instant recall exercise. > > What would you recommend for a quick cram to try to be as ready as possible > for such an interview? Skim the Camel book (Programming Perl) perhaps, if you have it? Read perldoc perltoc and look at any pages that are fuzzy? Look over perl code you've got hanging around and make sure you understand it? Chances are they'll be fairly lenient as far as minor misremembrances as long as you have the core algorithm and structure correct. (Nitpick: don't all-cap Perl.) -- Dave Isa. 40:31 From cos at indeterminate.net Sat Jan 21 11:54:35 2006 From: cos at indeterminate.net (John Costello) Date: Sat, 21 Jan 2006 11:54:35 -0800 (PST) Subject: SPUG: PERL technical interview In-Reply-To: <200601210706.k0L768q6025389@msa1-gh.centurytel.net> Message-ID: On Fri, 20 Jan 2006, Islandman wrote: > I have some job interviews coming up, one in PERL where I'm to do the "code > this on the fly on the whiteboard" exercise. I've worked in PERL quite a bit > over the years but during the last 2 years have had my mind warped by .NET > work and frankly feel awfully rusty for such an instant recall exercise. > > What would you recommend for a quick cram to try to be as ready as possible > for such an interview? Dust off your regexp. That's always useful. ----- John Costello - cos at indeterminate dot net From andrew at sweger.net Sat Jan 21 16:34:58 2006 From: andrew at sweger.net (Andrew Sweger) Date: Sat, 21 Jan 2006 16:34:58 -0800 (PST) Subject: SPUG: SPUG volunteer coordination mailing list In-Reply-To: Message-ID: Oops. It turns out "spug-admin" is a bad choice for a mail-list name on the Mailman system. It has special meaning internally to Mailman. I'll announce a replacement within a few days. For those already subscribed to spug-admin, you won't need to re-subscribe. Sorry for the delay. On Fri, 20 Jan 2006, Andrew Sweger wrote: > I have created (well, actually David Cross created) a mailing list for > SPUG activity coordination. This is to help support the distributed nature > of our volunteer efforts without cluttering this list with administrivia. > > The list is publicly archived and anyone is welcome to subscribe. > Currently, only subscribers may post to the list (but I suspect this will > need to change at some point). > > To subscribe, please go to the following link. > > http://mail.pm.org/mailman/listinfo/spug-admin > > Thank you. > > Ob-Perlish: > > David Golden has published his slides[1] for his Inside-Out Objects talk > at the recent Perl Seminar New York. Things have advanced even more since > Damian Conway's Perl Best Practices book; my first practical introduction > to the concept. I talked to David about visiting Seattle sometime this > year to give his presentation. He's itching for a PNW visit (perhaps to > coincide with OSCON '06). Keep your fingers crossed. > > [1] - http://dagolden.com/talks/20060117_whats_all_the_fuss.pdf > > -- Andrew B. Sweger -- The great thing about multitasking is that several things can go wrong at once. From creede at penguinsinthenight.com Sat Jan 21 23:04:59 2006 From: creede at penguinsinthenight.com (Creede Lambard) Date: Sat, 21 Jan 2006 23:04:59 -0800 Subject: SPUG: PERL technical interview In-Reply-To: <200601210706.k0L768q6025389@msa1-gh.centurytel.net> References: <200601210706.k0L768q6025389@msa1-gh.centurytel.net> Message-ID: <20060122070458.GB17641@boris.penguinsinthenight.com> Come up with a good way to reverse a string. I get asked that about two out of three interviews, it seems like. Oh, and no one seems to like print join ('', reverse( split (//, $string))); which seems unfair to me. I mean, if they're going to expect me to use Perl, I should be able to use Perl, not use Perl in a particular way they mandate (they seem to always want something that uses substr). You might also just want to go through a basic reference like O'Reilly's Perl Pocket Reference. In my experience the interviewers usually just ask simple stuff, like the aforementioned revering a string. I've had them ask me how to determine the intersection of two arrays (e.g. find the common elements between qw( a b c d e ) and qw( a h j c r ) and similar relatively simple problems. The most complicated question I ever had was how to create a system for parsing a particular kind of configuration file. The interviewer and I ended up collaborating on a pair of LIFO stacks working in tandem. (I got that job, by the way!) On Fri, Jan 20, 2006 at 11:06:07PM -0800, Islandman wrote: > I have some job interviews coming up, one in PERL where I'm to do the "code > this on the fly on the whiteboard" exercise. I've worked in PERL quite a bit > over the years but during the last 2 years have had my mind warped by .NET > work and frankly feel awfully rusty for such an instant recall exercise. > > What would you recommend for a quick cram to try to be as ready as possible > for such an interview? > > Thanks, > -Brian > -- =================================================================== * .~. ( : Creede Lambard : Never rush a miracle man. . / V \ . :------------------------: You get lousy miracles. /( )\ : creede at : --------------------------------^^-^^----: penguinsinthenight : Linux. Reliable and free. Pick any two. : dot com : =================================================================== From jarich at perltraining.com.au Sat Jan 21 23:22:09 2006 From: jarich at perltraining.com.au (Jacinta Richardson) Date: Sun, 22 Jan 2006 18:22:09 +1100 Subject: SPUG: PERL technical interview In-Reply-To: <20060122070458.GB17641@boris.penguinsinthenight.com> References: <200601210706.k0L768q6025389@msa1-gh.centurytel.net> <20060122070458.GB17641@boris.penguinsinthenight.com> Message-ID: <43D332A1.6040402@perltraining.com.au> Creede Lambard wrote: > Come up with a good way to reverse a string. I get asked that about two out > of three interviews, it seems like. Oh, and no one seems to like > > print join ('', reverse( split (//, $string))); What's wrong with: print scalar reverse $string; ? It's much less complicated. Or for those who get confused: print scalar( reverse $string ); Reverse in a list context reverses the elements of the list. To reverse a list of one element, you do nothing, so: print reverse $string; does nothing (print supplies a list context). Reverse in a scalar context concatenates its arguments and then reverses by character. The above solution could also be written: print reverse $string ."\n"; but that confuses people who then transcribe that with a comma, removing the scalar context that . supplies. ;) My favourite twist on this question is to ask: reverse a string: eg reverse this -> siht esrever reverse just the word order in the string: eg reverse this -> this reverse and then if you're feeling clever: reverse the words leaving them in place: eg reverse this -> esrever siht It's a good test to see if the person has a good grasp of context. All the best, Jacinta -- ("`-''-/").___..--''"`-._ | Jacinta Richardson | `6_ 6 ) `-. ( ).`-.__.`) | Perl Training Australia | (_Y_.)' ._ ) `._ `. ``-..-' | +61 3 9354 6001 | _..`--'_..-_/ /--'_.' ,' | contact at perltraining.com.au | (il),-'' (li),' ((!.-' | www.perltraining.com.au | From m3047 at inwa.net Sun Jan 22 10:55:03 2006 From: m3047 at inwa.net (Fred Morris) Date: Sun, 22 Jan 2006 10:55:03 -0800 Subject: SPUG: PERL technical interview Message-ID: An observation about current interviewing fads and developer team culture... What you're alluding to, I think, is the (questionable) notion that if you push people out of their realm of knowledge then you'll learn something (what, exactly?). In this scenario, whatever answer you give first is the "wrong" answer, they'll always want it done another way. The biggest pitfall is implied by your comments that you've come up with another way to do it: if you keep this from the interviewers and struggle a bit and then magically out pops another clever answer you've rigged the problem. The thing I hate about hypothetical white board problems in general are how poorly thought out they usually are, unless they are of the extremely simple and clever variety. Oftentimes the question and attempts at followup reveal a telling lack of grasp of the big picture by the interviewers themselves, and in that environment just how ultimately useful is cleverness going to prove to be? The interview question I haven't been asked lately... Which comes first: * optimization * correctness * working code At 11:04 PM 1/21/06, Creede Lambard wrote: >Come up with a good way to reverse a string. I get asked that about two out >of three interviews, it seems like. Oh, and no one seems to like > > print join ('', reverse( split (//, $string))); > >which seems unfair to me. I mean, if they're going to expect me to use Perl, >I should be able to use Perl, not use Perl in a particular way they mandate >(they seem to always want something that uses substr). [...] -- Fred Morris From jlb at io.com Sun Jan 22 11:05:19 2006 From: jlb at io.com (jlb) Date: Sun, 22 Jan 2006 13:05:19 -0600 (CST) Subject: SPUG: PERL technical interview In-Reply-To: References: Message-ID: <20060122130149.D71088@eris.io.com> I think the best Perl question I was ever asked in an interview was along the lines of "So, you like Perl, huh? Show me one of your favorite perl tricks." On the line of brushing up before an interview, I can't think of anything I'd recommend more than _Effective Perl Programming_ to start you thinking Perl again. Not that I'd use all the toys outlined in that book during an interview whiteboard session, but in me, at least, that book gets me thinking the right way. Jon From sthoenna at efn.org Sun Jan 22 21:48:13 2006 From: sthoenna at efn.org (Yitzchak Scott-Thoennes) Date: Sun, 22 Jan 2006 21:48:13 -0800 Subject: SPUG: PERL technical interview In-Reply-To: <20060122070458.GB17641@boris.penguinsinthenight.com> References: <200601210706.k0L768q6025389@msa1-gh.centurytel.net> <20060122070458.GB17641@boris.penguinsinthenight.com> Message-ID: <20060123054813.GA3172@efn.org> On Sat, Jan 21, 2006 at 11:04:59PM -0800, Creede Lambard wrote: > Come up with a good way to reverse a string. I get asked that about two out > of three interviews, it seems like. Oh, and no one seems to like > > print join ('', reverse( split (//, $string))); > > which seems unfair to me. I mean, if they're going to expect me to use Perl, > I should be able to use Perl, not use Perl in a particular way they mandate > (they seem to always want something that uses substr). So they want something like substr$string,0,0,substr$string,-1,1,""for 1..length$string ? From charles.e.derykus at boeing.com Mon Jan 23 05:47:17 2006 From: charles.e.derykus at boeing.com (DeRykus, Charles E) Date: Mon, 23 Jan 2006 05:47:17 -0800 Subject: SPUG: PERL technical interview Message-ID: On Sat, Jan 21, 2006 at 11:04:59PM -0800, Creede Lambard wrote: > Come up with a good way to reverse a string. I get asked that about > two out of three interviews, it seems like. Oh, and no one seems to > like > > print join ('', reverse( split (//, $string))); > > which seems unfair to me. I mean, if they're going to expect me to use > Perl, I should be able to use Perl, not use Perl in a particular way > they mandate (they seem to always want something that uses substr). YST >> So they want something like YST >> substr$string,0,0,substr$string,-1,1,""for 1..length$string Cool. If I look up substr's 4th arg and run Deparse, a self-consuming dragon comes into focus: $ perl -MO=Deparse,-p -e 'substr$string,0,0,substr$string,-1,1,""for 1..length' foreach $_ (1 .. length($string)) { substr($string, 0, 0, substr($string, (-1), 1, '')); } -e syntax OK Too bad interviews aren't Jeopardy-style :) -- Charles DeRykus From spud at spudzeppelin.com Mon Jan 23 08:32:58 2006 From: spud at spudzeppelin.com (Jeff Almeida) Date: Mon, 23 Jan 2006 10:32:58 -0600 Subject: SPUG: PERL technical interview In-Reply-To: References: Message-ID: <479E95FF-9CA6-4303-8254-FD457AB24406@spudzeppelin.com> correctness. at it's root (ok bad pun), all code is a collection of patches to / bin/true.... that is: int main() { return 1; } which is in a sense, the algebraic kernel of the software vector- space. it's also conveniently correct and canonically bug-free. any patch to this (that is, any collection of vectors added to this "zero" point) which introduces a bug breaks correctness. then from a practical perspective, the next two things are working code and optimization, which in most cases will iterate (you'll optimize something, then have to make it "work" again from some user's perspective, and so on).... my (slightly heavy) two cents, jeff On Jan 22, 2006, at 12:55 PM, Fred Morris wrote: > > > The interview question I haven't been asked lately... > > Which comes first: > > * optimization > * correctness > * working code > **************************************** Jeff D. Almeida * Corinth, TX spud at spudzeppelin.com **************************************** From rrue at fhcrc.org Mon Jan 23 09:30:03 2006 From: rrue at fhcrc.org (Randy Rue) Date: Mon, 23 Jan 2006 09:30:03 -0800 Subject: SPUG: PERL technical interview In-Reply-To: References: Message-ID: <43D5129B.4090109@fhcrc.org> Great question, and of course the short answer is "It depends." Years before I ever heard the project management term "triple constraint" a contractor friend of mine (contractor like hammer and nails and a white pickup truck, not like dev-for-hire) asked me if I wanted the job done "fast, cheap, or right, pick any two." I've never heard the concept explained better since. So the answer to "which comes first" depends on the situation and the priorities of the consumer. Is this app a heavy resource user? Tune it. Is it expected to be in use for a long time and maintained by baboons? Make it correct, avoid cryptic shortcuts, and comment the bejeezus out of it. Are we all fired if it's not running by noon? Fix it now! Assuming no constraints? Make it correct, even if it means getting not it working as quickly. Get it working. Then see about tuning it. My unsolicited $0.02. Randy Rue Fred Morris wrote: > The interview question I haven't been asked lately... > > Which comes first: > > * optimization > * correctness > * working code > > > At 11:04 PM 1/21/06, Creede Lambard wrote: > >>Come up with a good way to reverse a string. I get asked that about two out >>of three interviews, it seems like. Oh, and no one seems to like >> >> print join ('', reverse( split (//, $string))); >> >>which seems unfair to me. I mean, if they're going to expect me to use Perl, >>I should be able to use Perl, not use Perl in a particular way they mandate >>(they seem to always want something that uses substr). [...] > > > -- > > Fred Morris > > > _____________________________________________________________ > Seattle Perl Users Group Mailing List > POST TO: spug-list at pm.org > SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list > MEETINGS: 3rd Tuesdays > WEB PAGE: http://seattleperl.org/ From sthoenna at efn.org Mon Jan 23 09:59:59 2006 From: sthoenna at efn.org (Yitzchak Scott-Thoennes) Date: Mon, 23 Jan 2006 09:59:59 -0800 Subject: SPUG: PERL technical interview In-Reply-To: <479E95FF-9CA6-4303-8254-FD457AB24406@spudzeppelin.com> References: <479E95FF-9CA6-4303-8254-FD457AB24406@spudzeppelin.com> Message-ID: <20060123175959.GD2188@efn.org> On Mon, Jan 23, 2006 at 10:32:58AM -0600, Jeff Almeida wrote: > > > correctness. > > at it's root (ok bad pun), all code is a collection of patches to / > bin/true.... that is: > > int main() { > return 1; > } > > which is in a sense, the algebraic kernel of the software vector- > space. it's also conveniently correct and canonically bug-free. I've worked on a platform where the above is buggy. Canonically bug-free would be more like: #include #ifndef EXIT_SUCCESS #define EXIT_SUCCESS 1 #endif int main(int argc, char *argv[], char *envp[]) { return EXIT_SUCCESS; } From pdarley at kinesis-cem.com Mon Jan 23 10:06:00 2006 From: pdarley at kinesis-cem.com (Peter Darley) Date: Mon, 23 Jan 2006 10:06:00 -0800 Subject: SPUG: PERL technical interview In-Reply-To: <43D5129B.4090109@fhcrc.org> Message-ID: Folks, I gotta go with Correct first every time. Nobody cares how fast or stable a calculator is if it gives you 2+2=4345 or an email client is if it sends email to the wrong address. Thanks, Peter Darley -----Original Message----- From: spug-list-bounces at pm.org [mailto:spug-list-bounces at pm.org]On Behalf Of Randy Rue Sent: Monday, January 23, 2006 9:30 AM To: spug-list at pm.org Subject: Re: SPUG: PERL technical interview Great question, and of course the short answer is "It depends." Years before I ever heard the project management term "triple constraint" a contractor friend of mine (contractor like hammer and nails and a white pickup truck, not like dev-for-hire) asked me if I wanted the job done "fast, cheap, or right, pick any two." I've never heard the concept explained better since. So the answer to "which comes first" depends on the situation and the priorities of the consumer. Is this app a heavy resource user? Tune it. Is it expected to be in use for a long time and maintained by baboons? Make it correct, avoid cryptic shortcuts, and comment the bejeezus out of it. Are we all fired if it's not running by noon? Fix it now! Assuming no constraints? Make it correct, even if it means getting not it working as quickly. Get it working. Then see about tuning it. My unsolicited $0.02. Randy Rue From jazzdev at gmail.com Mon Jan 23 10:58:01 2006 From: jazzdev at gmail.com (JD Brennan) Date: Mon, 23 Jan 2006 10:58:01 -0800 Subject: SPUG: PERL technical interview In-Reply-To: <20060122070458.GB17641@boris.penguinsinthenight.com> References: <200601210706.k0L768q6025389@msa1-gh.centurytel.net> <20060122070458.GB17641@boris.penguinsinthenight.com> Message-ID: On 1/21/06, Creede Lambard wrote: > > Come up with a good way to reverse a string. I get asked that about two > out > of three interviews, it seems like. Oh, and no one seems to like > > print join ('', reverse( split (//, $string))); > > which seems unfair to me. I mean, if they're going to expect me to use > Perl, > I should be able to use Perl, not use Perl in a particular way they > mandate The goal of the interview coding question is to try to gain insight into how you think and how you tackle problems. So asking for more than one solution can enable the interviewer to gain more insight. JD -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/spug-list/attachments/20060123/0be58d33/attachment.html From jazzdev at gmail.com Mon Jan 23 11:02:44 2006 From: jazzdev at gmail.com (JD Brennan) Date: Mon, 23 Jan 2006 11:02:44 -0800 Subject: SPUG: PERL technical interview In-Reply-To: References: <43D5129B.4090109@fhcrc.org> Message-ID: That is a great question. And there's probably no one correct answer. My answer would be working code, since optimized code that doesn't work and correct code that doesn't work has less business value than working code. JD On 1/23/06, Randy Rue wrote: > > Great question, and of course the short answer is "It depends." > > Years before I ever heard the project management term "triple > constraint" a contractor friend of mine (contractor like hammer and > nails and a white pickup truck, not like dev-for-hire) asked me if I > wanted the job done "fast, cheap, or right, pick any two." I've never > heard the concept explained better since. > > So the answer to "which comes first" depends on the situation and the > priorities of the consumer. Is this app a heavy resource user? Tune it. > Is it expected to be in use for a long time and maintained by baboons? > Make it correct, avoid cryptic shortcuts, and comment the bejeezus out > of it. Are we all fired if it's not running by noon? Fix it now! > > Assuming no constraints? Make it correct, even if it means getting not > it working as quickly. Get it working. Then see about tuning it. > > My unsolicited $0.02. > > Randy Rue > > > > Fred Morris wrote: > > The interview question I haven't been asked lately... > > > > Which comes first: > > > > * optimization > > * correctness > > * working code > > > > > > At 11:04 PM 1/21/06, Creede Lambard wrote: > > > >>Come up with a good way to reverse a string. I get asked that about two > out > >>of three interviews, it seems like. Oh, and no one seems to like > >> > >> print join ('', reverse( split (//, $string))); > >> > >>which seems unfair to me. I mean, if they're going to expect me to use > Perl, > >>I should be able to use Perl, not use Perl in a particular way they > mandate > >>(they seem to always want something that uses substr). [...] > > > > > > -- > > > > Fred Morris > > > > > > _____________________________________________________________ > > Seattle Perl Users Group Mailing List > > POST TO: spug-list at pm.org > > SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list > > MEETINGS: 3rd Tuesdays > > WEB PAGE: http://seattleperl.org/ > _____________________________________________________________ > Seattle Perl Users Group Mailing List > POST TO: spug-list at pm.org > SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list > MEETINGS: 3rd Tuesdays > WEB PAGE: http://seattleperl.org/ > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/spug-list/attachments/20060123/0cddbbe8/attachment-0001.html From andrew at sweger.net Mon Jan 23 11:08:16 2006 From: andrew at sweger.net (Andrew Sweger) Date: Mon, 23 Jan 2006 11:08:16 -0800 (PST) Subject: SPUG: SPUG volunteer coordination mailing list In-Reply-To: Message-ID: The new list is now working and already humming with activity. To subscribe, please go to: http://mail.pm.org/mailman/listinfo/spug-workers That's right. The list name is SPUG-Workers. It almost sounds like a political party. SPUG Workers of the world untie! tie() should be deprecated anyway ;) On Sat, 21 Jan 2006, Andrew Sweger wrote: > Oops. It turns out "spug-admin" is a bad choice for a mail-list name on > the Mailman system. It has special meaning internally to Mailman. I'll > announce a replacement within a few days. For those already subscribed to > spug-admin, you won't need to re-subscribe. Sorry for the delay. -- Andrew B. Sweger -- The great thing about multitasking is that several things can go wrong at once. From spud at spudzeppelin.com Mon Jan 23 10:35:36 2006 From: spud at spudzeppelin.com (Jeff Almeida) Date: Mon, 23 Jan 2006 12:35:36 -0600 Subject: SPUG: OT: Re: PERL technical interview In-Reply-To: <20060123175959.GD2188@efn.org> References: <479E95FF-9CA6-4303-8254-FD457AB24406@spudzeppelin.com> <20060123175959.GD2188@efn.org> Message-ID: wow! forcing you to accept command-line arguments and potentially redefining a successful exit as something other than 1? mind if i ask which platform? but you're right of course -- what is "canonically bug-free" for a null program depends on your definition of the canon. jeff On Jan 23, 2006, at 11:59 AM, Yitzchak Scott-Thoennes wrote: > On Mon, Jan 23, 2006 at 10:32:58AM -0600, Jeff Almeida wrote: >> >> >> correctness. >> >> at it's root (ok bad pun), all code is a collection of patches to / >> bin/true.... that is: >> >> int main() { >> return 1; >> } >> >> which is in a sense, the algebraic kernel of the software vector- >> space. it's also conveniently correct and canonically bug-free. > > I've worked on a platform where the above is buggy. Canonically > bug-free > would be more like: > > #include > #ifndef EXIT_SUCCESS > #define EXIT_SUCCESS 1 > #endif > > int main(int argc, char *argv[], char *envp[]) { > return EXIT_SUCCESS; > } **************************************** Jeff D. Almeida * Corinth, TX spud at spudzeppelin.com **************************************** From m3047 at inwa.net Mon Jan 23 11:27:26 2006 From: m3047 at inwa.net (Fred Morris) Date: Mon, 23 Jan 2006 11:27:26 -0800 (PST) Subject: SPUG: OT: Re: PERL technical interview In-Reply-To: References: <479E95FF-9CA6-4303-8254-FD457AB24406@spudzeppelin.com> <20060123175959.GD2188@efn.org> Message-ID: I am so danged confused now. Completely blew off the fact that it wasn't Perl, and also that the exit code was 1. Now, if I recall correctly, 0 is success on .*[rn].*[sx]. Odd (e.g. 1) is success on VMS. Ob Perl: reblessing works very well, thanks. On Mon, 23 Jan 2006, Jeff Almeida wrote: > wow! forcing you to accept command-line arguments and potentially > redefining a successful exit as something other than 1? > > mind if i ask which platform? > > but you're right of course -- what is "canonically bug-free" for a > null program depends on your definition of the canon. > > jeff > > On Jan 23, 2006, at 11:59 AM, Yitzchak Scott-Thoennes wrote: > > > On Mon, Jan 23, 2006 at 10:32:58AM -0600, Jeff Almeida wrote: > >> > >> > >> correctness. > >> > >> at it's root (ok bad pun), all code is a collection of patches to / > >> bin/true.... that is: > >> > >> int main() { > >> return 1; > >> } > >> fred at twister:~> /bin/true fred at twister:~> echo $? 0 fred at twister:~> /bin/false fred at twister:~> echo $? 1 fred at twister:~> > >> which is in a sense, the algebraic kernel of the software vector- > >> space. it's also conveniently correct and canonically bug-free. > > > > I've worked on a platform where the above is buggy. Canonically > > bug-free > > would be more like: > > > > #include > > #ifndef EXIT_SUCCESS > > #define EXIT_SUCCESS 1 > > #endif > > > > int main(int argc, char *argv[], char *envp[]) { > > return EXIT_SUCCESS; > > } From spud at spudzeppelin.com Mon Jan 23 12:30:14 2006 From: spud at spudzeppelin.com (Jeff Almeida) Date: Mon, 23 Jan 2006 14:30:14 -0600 Subject: SPUG: OT: Re: PERL technical interview In-Reply-To: References: <479E95FF-9CA6-4303-8254-FD457AB24406@spudzeppelin.com> <20060123175959.GD2188@efn.org> Message-ID: <93A56BE0-2450-4AEF-834E-036986F55C20@spudzeppelin.com> *d'oh!* now you know why i don't code all that much in c *embarrassed grin* leave it to me to confuse shell-true with actual-true on a monday morning... jeff On Jan 23, 2006, at 1:27 PM, Fred Morris wrote: > I am so danged confused now. Completely blew off the fact that it > wasn't > Perl, and also that the exit code was 1. Now, if I recall > correctly, 0 is > success on .*[rn].*[sx]. Odd (e.g. 1) is success on VMS. > > Ob Perl: reblessing works very well, thanks. > > On Mon, 23 Jan 2006, Jeff Almeida wrote: > >> wow! forcing you to accept command-line arguments and potentially >> redefining a successful exit as something other than 1? >> >> mind if i ask which platform? >> >> but you're right of course -- what is "canonically bug-free" for a >> null program depends on your definition of the canon. >> >> jeff >> >> On Jan 23, 2006, at 11:59 AM, Yitzchak Scott-Thoennes wrote: >> >>> On Mon, Jan 23, 2006 at 10:32:58AM -0600, Jeff Almeida wrote: >>>> >>>> >>>> correctness. >>>> >>>> at it's root (ok bad pun), all code is a collection of patches to / >>>> bin/true.... that is: >>>> >>>> int main() { >>>> return 1; >>>> } >>>> > > fred at twister:~> /bin/true > fred at twister:~> echo $? > 0 > fred at twister:~> /bin/false > fred at twister:~> echo $? > 1 > fred at twister:~> > >>>> which is in a sense, the algebraic kernel of the software vector- >>>> space. it's also conveniently correct and canonically bug-free. >>> >>> I've worked on a platform where the above is buggy. Canonically >>> bug-free >>> would be more like: >>> >>> #include >>> #ifndef EXIT_SUCCESS >>> #define EXIT_SUCCESS 1 >>> #endif >>> >>> int main(int argc, char *argv[], char *envp[]) { >>> return EXIT_SUCCESS; >>> } > _____________________________________________________________ > Seattle Perl Users Group Mailing List > POST TO: spug-list at pm.org > SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list > MEETINGS: 3rd Tuesdays > WEB PAGE: http://seattleperl.org/ **************************************** Jeff D. Almeida * Corinth, TX spud at spudzeppelin.com **************************************** From sthoenna at efn.org Mon Jan 23 13:29:17 2006 From: sthoenna at efn.org (Yitzchak Scott-Thoennes) Date: Mon, 23 Jan 2006 13:29:17 -0800 Subject: SPUG: OT: Re: PERL technical interview In-Reply-To: <93A56BE0-2450-4AEF-834E-036986F55C20@spudzeppelin.com> References: <479E95FF-9CA6-4303-8254-FD457AB24406@spudzeppelin.com> <20060123175959.GD2188@efn.org> <93A56BE0-2450-4AEF-834E-036986F55C20@spudzeppelin.com> Message-ID: <20060123212917.GF2188@efn.org> On Mon, Jan 23, 2006 at 02:30:14PM -0600, Jeff Almeida wrote: > *d'oh!* now you know why i don't code all that much in c > *embarrassed grin* > > leave it to me to confuse shell-true with actual-true on a monday > morning... > > jeff Gah. I didn't notice either, just translated bin/true to EXIT_SUCCESS. That's a good reason to use EXIT_SUCCESS/EXIT_FAILURE :) I changed the signature of main() because I remember there being at least one compiler that would give an error if the usual parameters weren't specified. Don't remember what compiler/platform that was, or if envp was needed or not, now. WRT exit values, I think it was the CCS/C compiler on MPE/V (and maybe MPE/XL aka MPEiX) that supported MPE's concept of some return values indicating a warning rather than an error, so that EXIT_FAILURE needed to be high enough to indicate an actual failure. I think the HP C compiler has always translated any non-zero into a failure, though. From andrew at seattleperl.org Mon Jan 23 13:59:12 2006 From: andrew at seattleperl.org (Andrew Sweger) Date: Mon, 23 Jan 2006 13:59:12 -0800 (PST) Subject: SPUG: O'Reilly Gives Early Access to Cutting-Edge Technology Message-ID: O'Reilly's Safari Books Online has just announced a new service called Rough Cuts that gives you early access to content on cutting-edge technologies months before it's published. Rough Cuts allows you to purchase work-in-progress manuscripts of selected titles. You'll even have the chance to shape the final product by sending feedback to the author and editors. The beta version just debuted with four works-in-progress covering Ajax, Ruby, and Flickr. For more information, go to: http://www.oreilly.com/roughcuts/ Titles now available: Ajax Hacks: Rough Cuts Version http://www.oreilly.com/catalog/ajaxhks/ Flickr Hacks: Rough Cuts Version http://www.oreilly.com/catalog/flickrhks/ Ruby Cookbook: Rough Cuts Version http://www.oreilly.com/catalog/rubyckbk/ Ruby on Rails: Up and Running: Rough Cuts Version http://www.oreilly.com/catalog/rubyrails/ Rough Cuts FAQ http://www.oreilly.com/roughcuts/faq.csp From creede at penguinsinthenight.com Mon Jan 23 17:23:01 2006 From: creede at penguinsinthenight.com (Creede Lambard) Date: Mon, 23 Jan 2006 17:23:01 -0800 Subject: SPUG: PERL technical interview In-Reply-To: References: <200601210706.k0L768q6025389@msa1-gh.centurytel.net> <20060122070458.GB17641@boris.penguinsinthenight.com> Message-ID: <20060124012301.GI17641@boris.penguinsinthenight.com> On Mon, Jan 23, 2006 at 10:58:01AM -0800, JD Brennan wrote: > On 1/21/06, Creede Lambard wrote: > > > > Come up with a good way to reverse a string. I get asked that about two > > out > > of three interviews, it seems like. Oh, and no one seems to like > > > > print join ('', reverse( split (//, $string))); > > > > which seems unfair to me. I mean, if they're going to expect me to use > > Perl, > > I should be able to use Perl, not use Perl in a particular way they > > mandate > > > The goal of the interview coding question is to try > to gain insight into how you think and how you tackle > problems. So asking for more than one solution can > enable the interviewer to gain more insight. > That's a valid point, but somehow it invariably gets expressed as "No, I don't want you to do it that way" as opposed to "Can you do it another way as well?" -- =================================================================== * .~. ( : Creede Lambard : Never rush a miracle man. . / V \ . :------------------------: You get lousy miracles. /( )\ : creede at : --------------------------------^^-^^----: penguinsinthenight : Linux. Reliable and free. Pick any two. : dot com : =================================================================== From creede at penguinsinthenight.com Mon Jan 23 17:33:00 2006 From: creede at penguinsinthenight.com (Creede Lambard) Date: Mon, 23 Jan 2006 17:33:00 -0800 Subject: SPUG: PERL technical interview In-Reply-To: <43D332A1.6040402@perltraining.com.au> References: <200601210706.k0L768q6025389@msa1-gh.centurytel.net> <20060122070458.GB17641@boris.penguinsinthenight.com> <43D332A1.6040402@perltraining.com.au> Message-ID: <20060124013259.GJ17641@boris.penguinsinthenight.com> On Sun, Jan 22, 2006 at 06:22:09PM +1100, Jacinta Richardson wrote: > > Creede Lambard wrote: > > Come up with a good way to reverse a string. I get asked that about two out > > of three interviews, it seems like. Oh, and no one seems to like > > > > print join ('', reverse( split (//, $string))); > > What's wrong with: > > print scalar reverse $string; > Not a thing if it works as advertised :) > ? It's much less complicated. Sez you. :) I have trouble remembering contexts sometimes, but I have no trouble remembering the join-reverse-split construction. It may also come under the heading of expanding your code to improve readability. I think part of the problem is that I am often interviewed by C coders who are used to thinking in terms of reversing an array of chars with a loop rather than with a single command. These same people are often surprised that "unless" works as a keyword when I drop it into a piece of code as an equivalent for "if not". -- =================================================================== * .~. ( : Creede Lambard : Never rush a miracle man. . / V \ . :------------------------: You get lousy miracles. /( )\ : creede at : --------------------------------^^-^^----: penguinsinthenight : Linux. Reliable and free. Pick any two. : dot com : =================================================================== From m3047 at inwa.net Mon Jan 23 18:28:53 2006 From: m3047 at inwa.net (Fred Morris) Date: Mon, 23 Jan 2006 18:28:53 -0800 Subject: SPUG: can't leave well enough alone Re: PERL technical interview Message-ID: Take two, the function is named EXIT_SUCCESS.. OK, you can shoot me now. This code scares me; I worry about what might be assuming something entirely reasonable about EXIT_SUCCESS being defined as a macro... But it runs on the linux box sitting here on the desk. I'm done, I promise! #!/usr/bin/perl -w use Inline C; use strict; print 'EXIT_SUCCESS is '; if (defined( my $code = &EXIT_SUCCESS)) { print "defined as $code\n"; exit($code); } else { print "undefined\n"; } __END__ __C__ #include #ifdef EXIT_SUCCESS static int saved_code_defined = 1; static int saved_code = EXIT_SUCCESS; #undef EXIT_SUCCESS #else static int saved_code_defined = 0; static int saved_code = 0; #endif void EXIT_SUCCESS() { Inline_Stack_Vars; Inline_Stack_Reset; if (saved_code_defined) { Inline_Stack_Push(sv_2mortal(newSViv(saved_code))); } else { Inline_Stack_Push(sv_2mortal(newSV(0))); } Inline_Stack_Done; } -- Fred Morris From m3047 at inwa.net Mon Jan 23 16:21:52 2006 From: m3047 at inwa.net (Fred Morris) Date: Mon, 23 Jan 2006 16:21:52 -0800 Subject: SPUG: PERL technical interview Message-ID: Don't ask me to do this in an interview, but I couldn't resist. #!/usr/bin/perl -w use Inline C; use strict; print 'EXIT_SUCCESS is '; if (defined( my $code = &SHELL_SUCCESS)) { print "defined as $code\n"; exit($code); } else { print "undefined\n"; } __END__ __C__ #include void SHELL_SUCCESS() { Inline_Stack_Vars; Inline_Stack_Reset; #ifdef EXIT_SUCCESS Inline_Stack_Push(sv_2mortal(newSViv(EXIT_SUCCESS))); #else Inline_Stack_Push(sv_2mortal(newSV(0))); #endif Inline_Stack_Done; } -- Fred Morris -- At 9:59 AM 1/23/06, Yitzchak Scott-Thoennes wrote: >[...] >I've worked on a platform where the above is buggy. Canonically bug-free >would be more like: > >#include >#ifndef EXIT_SUCCESS >#define EXIT_SUCCESS 1 >#endif > >int main(int argc, char *argv[], char *envp[]) { > return EXIT_SUCCESS; >} From schieb at centurytel.net Tue Jan 24 10:54:26 2006 From: schieb at centurytel.net (Brian Schieber) Date: Tue, 24 Jan 2006 10:54:26 -0800 Subject: SPUG: How it went In-Reply-To: <200601241724.k0OHOnJO073546@mx3.centurytel.net> Message-ID: <200601241854.k0OIsQra028418@msa1-gh.centurytel.net> > -----Original Message----- > From: Michael R. Wolf [mailto:MichaelRWolf at att.net] > Sent: Tuesday, January 24, 2006 9:25 AM > To: 'Brian Schieber' > Subject: How it went > > Could you post a response to SPUG telling folks how it went? It generated > one of the longest threads in a while. > > -- > Michael R. Wolf > All mammals learn by playing! > MichaelRWolf at att.net > Sure. The interview went well but no one ever gave me a test. Maybe that will come later. Still, it was good to review Perl before going in. I've missed working in it. Thanks for all the help from all those who responded. -Brian From sthoenna at efn.org Tue Jan 24 12:09:23 2006 From: sthoenna at efn.org (Yitzchak Scott-Thoennes) Date: Tue, 24 Jan 2006 12:09:23 -0800 Subject: SPUG: PERL technical interview In-Reply-To: References: Message-ID: <20060124200923.GA3620@efn.org> On Mon, Jan 23, 2006 at 04:21:52PM -0800, Fred Morris wrote: > Don't ask me to do this in an interview, but I couldn't resist. > > #!/usr/bin/perl -w > > use Inline C; ... > #include > > void SHELL_SUCCESS() { > > Inline_Stack_Vars; > Inline_Stack_Reset; > > #ifdef EXIT_SUCCESS > Inline_Stack_Push(sv_2mortal(newSViv(EXIT_SUCCESS))); > #else > Inline_Stack_Push(sv_2mortal(newSV(0))); > #endif Just FYI, $ perl -wl use POSIX "/EXIT_*/"; print "EXIT_SUCCESS is @{[EXIT_SUCCESS]}, EXIT_FAILURE is @{[EXIT_FAILURE]}"; __END__ EXIT_SUCCESS is 0, EXIT_FAILURE is 1 From atom.powers at gmail.com Wed Jan 25 10:28:55 2006 From: atom.powers at gmail.com (Atom Powers) Date: Wed, 25 Jan 2006 10:28:55 -0800 Subject: SPUG: geting the perl version Message-ID: I want to do this: `/usr/bin/perl -V:version | /usr/bin/cut -d "'" -f 2` without using pipes or quotes; is that possible? (for some reason my application isn't executing this correctly) That is; I am looking for a simple way to get just the version number wihout any padding. Something like "5.8.7" or "5.0.6" or whatever. -- -- Perfection is just a word I use occasionally with mustard. --Atom Powers-- From cmeyer at helvella.org Wed Jan 25 10:34:21 2006 From: cmeyer at helvella.org (Colin Meyer) Date: Wed, 25 Jan 2006 10:34:21 -0800 Subject: SPUG: geting the perl version In-Reply-To: References: Message-ID: <20060125183421.GU13359@funpox.helvella.org> On Wed, Jan 25, 2006 at 10:28:55AM -0800, Atom Powers wrote: > I want to do this: `/usr/bin/perl -V:version | /usr/bin/cut -d "'" -f > 2` without using pipes or quotes; is that possible? (for some reason > my application isn't executing this correctly) > > That is; I am looking for a simple way to get just the version number > wihout any padding. Something like "5.8.7" or "5.0.6" or whatever. >From the perlvar manpage: perl -e'printf "version is v%vd\n", $^V' -Colin. From jerry.gay at gmail.com Wed Jan 25 10:35:00 2006 From: jerry.gay at gmail.com (jerry gay) Date: Wed, 25 Jan 2006 10:35:00 -0800 Subject: SPUG: geting the perl version In-Reply-To: References: Message-ID: <1d9a3f400601251035n44677a34re9cdb76527cc3e1c@mail.gmail.com> On 1/25/06, Atom Powers wrote: > > I want to do this: `/usr/bin/perl -V:version | /usr/bin/cut -d "'" -f > 2` without using pipes or quotes; is that possible? (for some reason > my application isn't executing this correctly) > > That is; I am looking for a simple way to get just the version number > wihout any padding. Something like "5.8.7" or "5.0.6" or whatever. maybe this will help: perl -MConfig -e"print $Config{version}" ~jerry -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/spug-list/attachments/20060125/46efb55a/attachment.html From cmeyer at helvella.org Wed Jan 25 10:37:27 2006 From: cmeyer at helvella.org (Colin Meyer) Date: Wed, 25 Jan 2006 10:37:27 -0800 Subject: SPUG: geting the perl version In-Reply-To: <1d9a3f400601251035n44677a34re9cdb76527cc3e1c@mail.gmail.com> References: <1d9a3f400601251035n44677a34re9cdb76527cc3e1c@mail.gmail.com> Message-ID: <20060125183727.GV13359@funpox.helvella.org> On Wed, Jan 25, 2006 at 10:35:00AM -0800, jerry gay wrote: > On 1/25/06, Atom Powers wrote: > > > > I want to do this: `/usr/bin/perl -V:version | /usr/bin/cut -d "'" -f > > 2` without using pipes or quotes; is that possible? (for some reason > > my application isn't executing this correctly) > > > > That is; I am looking for a simple way to get just the version number > > wihout any padding. Something like "5.8.7" or "5.0.6" or whatever. > > > > maybe this will help: > perl -MConfig -e"print $Config{version}" Most shells interpolate $variables within double quotes, so this may work better for you: perl -MConfig -le'print $Config{version}' -Colin. From atom.powers at gmail.com Wed Jan 25 10:45:28 2006 From: atom.powers at gmail.com (Atom Powers) Date: Wed, 25 Jan 2006 10:45:28 -0800 Subject: SPUG: geting the perl version In-Reply-To: <20060125183727.GV13359@funpox.helvella.org> References: <1d9a3f400601251035n44677a34re9cdb76527cc3e1c@mail.gmail.com> <20060125183727.GV13359@funpox.helvella.org> Message-ID: Thank you, that does whan I want. But still doesn't work from within my application. On 1/25/06, Colin Meyer wrote: > On Wed, Jan 25, 2006 at 10:35:00AM -0800, jerry gay wrote: > > On 1/25/06, Atom Powers wrote: > > > > > > I want to do this: `/usr/bin/perl -V:version | /usr/bin/cut -d "'" -f > > > 2` without using pipes or quotes; is that possible? (for some reason > > > my application isn't executing this correctly) > > > > > > That is; I am looking for a simple way to get just the version number > > > wihout any padding. Something like "5.8.7" or "5.0.6" or whatever. > > > > > > > > maybe this will help: > > perl -MConfig -e"print $Config{version}" > > Most shells interpolate $variables within double quotes, so this > may work better for you: > > perl -MConfig -le'print $Config{version}' > > -Colin. > -- -- Perfection is just a word I use occasionally with mustard. --Atom Powers-- From bill at celestial.com Wed Jan 25 10:48:30 2006 From: bill at celestial.com (Bill Campbell) Date: Wed, 25 Jan 2006 10:48:30 -0800 Subject: SPUG: geting the perl version In-Reply-To: References: Message-ID: <20060125184830.GC75654@alexis.mi.celestial.com> On Wed, Jan 25, 2006, Atom Powers wrote: >I want to do this: `/usr/bin/perl -V:version | /usr/bin/cut -d "'" -f >2` without using pipes or quotes; is that possible? (for some reason >my application isn't executing this correctly) > >That is; I am looking for a simple way to get just the version number >wihout any padding. Something like "5.8.7" or "5.0.6" or whatever. If you're doing this from the shell, this should set a shell variable, version: eval `perl -V:version` Bill -- INTERNET: bill at Celestial.COM Bill Campbell; Celestial Software LLC URL: http://www.celestial.com/ PO Box 820; 6641 E. Mercer Way FAX: (206) 232-9186 Mercer Island, WA 98040-0820; (206) 236-1676 ``Unix is simple. It just takes a genius to understand its simplicity'' -- Dennis Ritchie From cmeyer at helvella.org Wed Jan 25 10:53:39 2006 From: cmeyer at helvella.org (Colin Meyer) Date: Wed, 25 Jan 2006 10:53:39 -0800 Subject: SPUG: geting the perl version In-Reply-To: References: <1d9a3f400601251035n44677a34re9cdb76527cc3e1c@mail.gmail.com> <20060125183727.GV13359@funpox.helvella.org> Message-ID: <20060125185339.GW13359@funpox.helvella.org> On Wed, Jan 25, 2006 at 10:45:28AM -0800, Atom Powers wrote: > Thank you, that does whan I want. > But still doesn't work from within my application. Why not? I just inserted that code, and the $^V style (with sprintf instead of printf) into an application, and they both worked fine. # assuming that your application is also a Perl program # my $version = sprintf "%vd", $^V; some_routine_that_wants_the_version( $version ); -Colin. From atom.powers at gmail.com Wed Jan 25 11:01:56 2006 From: atom.powers at gmail.com (Atom Powers) Date: Wed, 25 Jan 2006 11:01:56 -0800 Subject: SPUG: geting the perl version In-Reply-To: <20060125185539.GA2556@efn.org> References: <1d9a3f400601251035n44677a34re9cdb76527cc3e1c@mail.gmail.com> <20060125183727.GV13359@funpox.helvella.org> <20060125185539.GA2556@efn.org> Message-ID: I have tried all of these: PerlVer = ( ExecResult(/usr/bin/perl -V:version | /usr/bin/cut -d "'" -f 2) ) PerlVer = ( ExecResult(/usr/bin/perl -e'printf "%vd\n", $^V') ) PerlVer = ( ExecResult(/usr/bin/perl -MConfig -le'print $Config{version}') ) The first one returs "version='5.8.7';" The rest ruturn "Can't find string terminator "'" anywhere before EOF at -e line 1." This leads me to believe that the ExecResult function doesn't quotes. On 1/25/06, Yitzchak Scott-Thoennes wrote: > On Wed, Jan 25, 2006 at 10:45:28AM -0800, Atom Powers wrote: > > Thank you, that does whan I want. > > But still doesn't work from within my application. > > Can you show how you are trying to invoke perl in your application? > What does "doesn't work" mean? Bad output? No output? Error messages? > Does it actually find perl on the path? > -- -- Perfection is just a word I use occasionally with mustard. --Atom Powers-- From atom.powers at gmail.com Wed Jan 25 11:08:14 2006 From: atom.powers at gmail.com (Atom Powers) Date: Wed, 25 Jan 2006 11:08:14 -0800 Subject: SPUG: geting the perl version In-Reply-To: <20060125185819.GB2556@efn.org> References: <20060125185819.GB2556@efn.org> Message-ID: On 1/25/06, Yitzchak Scott-Thoennes wrote: > Here's a quoteless way: > > perl -eprint+eval~~join+undef,map+chr,36,93 > Oooh, that looks promising... Nope: "cf:cfengine::./test.cf:9: Function or format of input file requires 1 argument items" I think I'm going to have to write a wrapper. -- -- Perfection is just a word I use occasionally with mustard. --Atom Powers-- From atom.powers at gmail.com Wed Jan 25 11:19:51 2006 From: atom.powers at gmail.com (Atom Powers) Date: Wed, 25 Jan 2006 11:19:51 -0800 Subject: SPUG: geting the perl version In-Reply-To: <20060125191553.GD2556@efn.org> References: <20060125185819.GB2556@efn.org> <20060125191553.GD2556@efn.org> Message-ID: On 1/25/06, Yitzchak Scott-Thoennes wrote: > No commas allowed, huh? That makes it tough. Does it pass through > $? If so, just: perl -eprint -e$] > Yes! cfengine:: PERL_VER=5.008007 -- -- Perfection is just a word I use occasionally with mustard. --Atom Powers-- From umar at drizzle.com Wed Jan 25 11:19:20 2006 From: umar at drizzle.com (Umar Cheema) Date: Wed, 25 Jan 2006 11:19:20 -0800 (PST) Subject: SPUG: geting the perl version In-Reply-To: Message-ID: If your application is Perl based, do you really have to use a shell command? Can't you simply use the Config module from within Perl? use Config; my $version = $Config{version}; On Wed, 25 Jan 2006, Atom Powers wrote: On 1/25/06, Yitzchak Scott-Thoennes wrote: > Here's a quoteless way: > > perl -eprint+eval~~join+undef,map+chr,36,93 > Oooh, that looks promising... Nope: "cf:cfengine::./test.cf:9: Function or format of input file requires 1 argument items" I think I'm going to have to write a wrapper. -- -- Perfection is just a word I use occasionally with mustard. --Atom Powers-- _____________________________________________________________ Seattle Perl Users Group Mailing List POST TO: spug-list at pm.org SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list MEETINGS: 3rd Tuesdays WEB PAGE: http://seattleperl.org/ From umar at drizzle.com Wed Jan 25 11:26:23 2006 From: umar at drizzle.com (Umar Cheema) Date: Wed, 25 Jan 2006 11:26:23 -0800 (PST) Subject: SPUG: geting the perl version In-Reply-To: Message-ID: Nevermind. I just read the other emails. On Wed, 25 Jan 2006, Umar Cheema wrote: If your application is Perl based, do you really have to use a shell command? Can't you simply use the Config module from within Perl? use Config; my $version = $Config{version}; On Wed, 25 Jan 2006, Atom Powers wrote: On 1/25/06, Yitzchak Scott-Thoennes wrote: > Here's a quoteless way: > > perl -eprint+eval~~join+undef,map+chr,36,93 > Oooh, that looks promising... Nope: "cf:cfengine::./test.cf:9: Function or format of input file requires 1 argument items" I think I'm going to have to write a wrapper. -- -- Perfection is just a word I use occasionally with mustard. --Atom Powers-- _____________________________________________________________ Seattle Perl Users Group Mailing List POST TO: spug-list at pm.org SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list MEETINGS: 3rd Tuesdays WEB PAGE: http://seattleperl.org/ From andrew at sweger.net Wed Jan 25 11:46:16 2006 From: andrew at sweger.net (Andrew Sweger) Date: Wed, 25 Jan 2006 11:46:16 -0800 (PST) Subject: SPUG: geting the perl version In-Reply-To: Message-ID: On Wed, 25 Jan 2006, Atom Powers wrote: > I want to do this: `/usr/bin/perl -V:version | /usr/bin/cut -d "'" -f > 2` without using pipes or quotes; is that possible? (for some reason > my application isn't executing this correctly) > > That is; I am looking for a simple way to get just the version number > wihout any padding. Something like "5.8.7" or "5.0.6" or whatever. I think it would have been helpful to mention from the start that the application in question was cfengine. -- Andrew B. Sweger -- The great thing about multitasking is that several things can go wrong at once. From chuck.orr at cingular.com Wed Jan 25 12:50:17 2006 From: chuck.orr at cingular.com (Orr, Chuck (NOC)) Date: Wed, 25 Jan 2006 12:50:17 -0800 Subject: SPUG: Symbolic references ??? Message-ID: Hello, I have a group of 5 arrays, named as follows: my @ofcrte; my @pxrte; my @acrte; my @farte; my @ftrte; I would like to push something on to one of them per iteration of a loop, the pushee determined by a variable named $lc_table. If I read pgs 16 & 17 of the leopard (advanced perl programming) correctly, I should be able to use a symbolic reference to push to the appropriate array depending on the contents of the $lc_table variable. I have turned strict refs off within the loop. here is my push line: push @$lc_table, "rep bla bla bla bla bla"; when I then print the above listed arrays, they have nothing in them. However, if I print "@$lc_table"; within the loop, there are elements in the array. Any suggestions? If anyone can help me and has time to look at a little more code, I would be glad to send it. Thanks for your help, Chuck Orr chuck.orr at cingular.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/spug-list/attachments/20060125/9b81ffd5/attachment.html From cmeyer at helvella.org Wed Jan 25 13:00:42 2006 From: cmeyer at helvella.org (Colin Meyer) Date: Wed, 25 Jan 2006 13:00:42 -0800 Subject: SPUG: Symbolic references ??? In-Reply-To: References: Message-ID: <20060125210042.GX13359@funpox.helvella.org> Hi Chuck, On Wed, Jan 25, 2006 at 12:50:17PM -0800, Orr, Chuck (NOC) wrote: > > Hello, > > I have a group of 5 arrays, named as follows: > > my @ofcrte; > my @pxrte; > my @acrte; > my @farte; > my @ftrte; Great variable names! ;-) > > I would like to push something on to one of them per iteration of a > loop, the pushee determined by a variable named $lc_table. > > If I read pgs 16 & 17 of the leopard (advanced perl programming) > correctly, I should be able to use a symbolic reference to push to the > appropriate array depending on the contents of the $lc_table variable. > I have turned strict refs off within the loop. > > here is my push line: > > push @$lc_table, "rep bla bla bla bla bla"; > > when I then print the above listed arrays, they have nothing in them. > However, if I print "@$lc_table"; within the loop, there are elements in > the array. Any suggestions? A typical approach to your problem would be to use one hash, with keys of the same names as your old arrays, and values of arrayrefs. my %table; # this hash will hold the arrays for my $value_to_push ( function_that_generates_values() ) { push @{ $table{ $lc_table } }, $value_to_push; } # later, read out some values print "the last value of ofcrte is: $table{ ofcrte }[ -1 ] \n"; -Colin. From tallpeak at hotmail.com Wed Jan 25 13:24:08 2006 From: tallpeak at hotmail.com (Aaron West) Date: Wed, 25 Jan 2006 13:24:08 -0800 Subject: SPUG: Weirdness in map In-Reply-To: Message-ID: After the last post, I was wondering if I had any .cf files in my coldfusion directory....and wrote this one-liner. Any idea why these have different output? In the first, the reverse inside the map apparently doesn't work. It's as if sprintf is looking at the original value of $_ before it was reversed, somehow. So I appended "" to the value returned by reverse, in the second version, and it worked!??? ======================================== Version 1: [user at machinename] /cygdrive/c/CFusionMX $ find . -name "*.cf*" | \ perl -nle '($_) = split("\\.", reverse($_), 2); $extr{$_}++; END{print map {sprintf("%s\t%d\n", reverse($_), $extr{$_}) } sort keys %extr}' cfc 19 dlo 1 dltfc 1 gfc 1 mfc 959 ~1~ 1 ======================================== Version 2: [user at machinename] /cygdrive/c/CFusionMX find . -name "*.cf*" | \ perl -nle '($_) = split("\\.", reverse($_), 2); $extr{$_}++; END{print map {sprintf("%s\t%d\n", reverse($_) . "", $extr{$_}) } sort keys %extr}' cfc 19 old 1 cftld 1 cfg 1 cfm 959 ~1~ 1 ======================================== $ perl -v This is perl, v5.8.7 built for cygwin-thread-multi-64int (with 1 registered patch, see perl -V for more detail) .. From tallpeak at hotmail.com Wed Jan 25 13:28:56 2006 From: tallpeak at hotmail.com (Aaron West) Date: Wed, 25 Jan 2006 13:28:56 -0800 Subject: SPUG: Weirdness in map In-Reply-To: Message-ID: PS. Simplified example. $ perl -le '@a="abc";print map {reverse $_} @a' abc $ perl -le '@a="abc";print map {(reverse $_).""} @a' cba -----Original Message----- From: spug-list-bounces+tallpeak=hotmail.com at pm.org [mailto:spug-list-bounces+tallpeak=hotmail.com at pm.org] On Behalf Of Aaron West Sent: Wednesday, January 25, 2006 1:24 PM To: 'SPUG Members' Subject: SPUG: Weirdness in map After the last post, I was wondering if I had any .cf files in my coldfusion directory....and wrote this one-liner. Any idea why these have different output? In the first, the reverse inside the map apparently doesn't work. It's as if sprintf is looking at the original value of $_ before it was reversed, somehow. So I appended "" to the value returned by reverse, in the second version, and it worked!??? ======================================== Version 1: [user at machinename] /cygdrive/c/CFusionMX $ find . -name "*.cf*" | \ perl -nle '($_) = split("\\.", reverse($_), 2); $extr{$_}++; END{print map {sprintf("%s\t%d\n", reverse($_), $extr{$_}) } sort keys %extr}' cfc 19 dlo 1 dltfc 1 gfc 1 mfc 959 ~1~ 1 ======================================== Version 2: [user at machinename] /cygdrive/c/CFusionMX find . -name "*.cf*" | \ perl -nle '($_) = split("\\.", reverse($_), 2); $extr{$_}++; END{print map {sprintf("%s\t%d\n", reverse($_) . "", $extr{$_}) } sort keys %extr}' cfc 19 old 1 cftld 1 cfg 1 cfm 959 ~1~ 1 ======================================== $ perl -v This is perl, v5.8.7 built for cygwin-thread-multi-64int (with 1 registered patch, see perl -V for more detail) . _____________________________________________________________ Seattle Perl Users Group Mailing List POST TO: spug-list at pm.org SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list MEETINGS: 3rd Tuesdays WEB PAGE: http://seattleperl.org/ From tallpeak at hotmail.com Wed Jan 25 13:35:13 2006 From: tallpeak at hotmail.com (Aaron West) Date: Wed, 25 Jan 2006 13:35:13 -0800 Subject: SPUG: Weirdness in map In-Reply-To: Message-ID: Nevermind. The context within print is list context, and reverse in list context reverses a list. $ perl -Wle 'print reverse("asdf")' asdf $ perl -Wle 'print scalar reverse("asdf")' fdsa -----Original Message----- From: Aaron West [mailto:tallpeak at hotmail.com] Sent: Wednesday, January 25, 2006 1:29 PM To: 'SPUG Members' Subject: RE: SPUG: Weirdness in map PS. Simplified example. $ perl -le '@a="abc";print map {reverse $_} @a' abc $ perl -le '@a="abc";print map {(reverse $_).""} @a' cba -----Original Message----- From: spug-list-bounces+tallpeak=hotmail.com at pm.org [mailto:spug-list-bounces+tallpeak=hotmail.com at pm.org] On Behalf Of Aaron West Sent: Wednesday, January 25, 2006 1:24 PM To: 'SPUG Members' Subject: SPUG: Weirdness in map After the last post, I was wondering if I had any .cf files in my coldfusion directory....and wrote this one-liner. Any idea why these have different output? In the first, the reverse inside the map apparently doesn't work. It's as if sprintf is looking at the original value of $_ before it was reversed, somehow. So I appended "" to the value returned by reverse, in the second version, and it worked!??? ======================================== Version 1: [user at machinename] /cygdrive/c/CFusionMX $ find . -name "*.cf*" | \ perl -nle '($_) = split("\\.", reverse($_), 2); $extr{$_}++; END{print map {sprintf("%s\t%d\n", reverse($_), $extr{$_}) } sort keys %extr}' cfc 19 dlo 1 dltfc 1 gfc 1 mfc 959 ~1~ 1 ======================================== Version 2: [user at machinename] /cygdrive/c/CFusionMX find . -name "*.cf*" | \ perl -nle '($_) = split("\\.", reverse($_), 2); $extr{$_}++; END{print map {sprintf("%s\t%d\n", reverse($_) . "", $extr{$_}) } sort keys %extr}' cfc 19 old 1 cftld 1 cfg 1 cfm 959 ~1~ 1 ======================================== $ perl -v This is perl, v5.8.7 built for cygwin-thread-multi-64int (with 1 registered patch, see perl -V for more detail) .. _____________________________________________________________ Seattle Perl Users Group Mailing List POST TO: spug-list at pm.org SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list MEETINGS: 3rd Tuesdays WEB PAGE: http://seattleperl.org/ From torin.darren at gmail.com Wed Jan 25 13:52:46 2006 From: torin.darren at gmail.com (Darren Stalder) Date: Wed, 25 Jan 2006 13:52:46 -0800 Subject: SPUG: Weirdness in map In-Reply-To: References: Message-ID: <91dff6490601251352s781cdca8x8c6400ce2fb2af73@mail.gmail.com> In the first case, the reverse is in list context and reverses the list of ($_). The reverse of a list with one element is that same list. Once you append "" to reverse($_), you're putting it into scalar context where reverse does what you're expecting. Darren On 1/25/06, Aaron West wrote: > After the last post, I was wondering if I had any .cf files in my coldfusion > directory....and wrote this one-liner. Any idea why these have different > output? > > In the first, the reverse inside the map apparently doesn't work. It's as if > sprintf is looking at the original value of $_ before it was reversed, > somehow. So I appended "" to the value returned by reverse, in the second > version, and it worked!??? > > ======================================== > Version 1: > > [user at machinename] /cygdrive/c/CFusionMX > $ find . -name "*.cf*" | \ > perl -nle '($_) = split("\\.", reverse($_), 2); > $extr{$_}++; > END{print map {sprintf("%s\t%d\n", reverse($_), $extr{$_}) } > sort keys %extr}' > cfc 19 > dlo 1 > dltfc 1 > gfc 1 > mfc 959 > ~1~ 1 > > ======================================== > Version 2: > > [user at machinename] /cygdrive/c/CFusionMX > find . -name "*.cf*" | \ > perl -nle '($_) = split("\\.", reverse($_), 2); > $extr{$_}++; > END{print map {sprintf("%s\t%d\n", reverse($_) . "", $extr{$_}) } > sort keys %extr}' > cfc 19 > old 1 > cftld 1 > cfg 1 > cfm 959 > ~1~ 1 > > ======================================== > > $ perl -v > > This is perl, v5.8.7 built for cygwin-thread-multi-64int > (with 1 registered patch, see perl -V for more detail) > .. > _____________________________________________________________ > Seattle Perl Users Group Mailing List > POST TO: spug-list at pm.org > SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list > MEETINGS: 3rd Tuesdays > WEB PAGE: http://seattleperl.org/ > From sthoenna at efn.org Wed Jan 25 14:03:20 2006 From: sthoenna at efn.org (Yitzchak Scott-Thoennes) Date: Wed, 25 Jan 2006 14:03:20 -0800 Subject: SPUG: PERL technical interview In-Reply-To: <20060124200923.GA3620@efn.org> References: <20060124200923.GA3620@efn.org> Message-ID: <20060125220320.GA3168@efn.org> On Tue, Jan 24, 2006 at 12:09:23PM -0800, Yitzchak Scott-Thoennes wrote: > $ perl -wl > use POSIX "/EXIT_*/"; > print "EXIT_SUCCESS is @{[EXIT_SUCCESS]}, EXIT_FAILURE is @{[EXIT_FAILURE]}"; > __END__ > EXIT_SUCCESS is 0, EXIT_FAILURE is 1 I had a response from someone whom this syntax gave momentary pause, so I thought I'd try to explain it. @{[ expr ]} is an idiomatic way of embedding an arbitrary expression in a double-quoted string. It executes expr in list context (which makes no difference for these constants) and interpolates the result into the string. (If there are multiple items in the result, they are separated by $" aka $LIST_SEPARATOR, which defaults to a space.) Taking it apart, first there's the @ which introduces an array to be interpolated into the string. This has three basic forms: @identifier, @{identifier}, and @{arrayref}. The second form uses the {} just to delimit the identifier name, as when there is a word character immediately following: @foo="foo"; $foobar="@{foo}bar"; The third form is just like @ followed by a BLOCK outside of double quoted string; the code in the BLOCK is executed and the result is treated as an array reference to dereference. In this case, the code in the BLOCK is just an anonymous array constructor: [ expr ]. Putting it all together, EXIT_SUCCESS calls the function of that name, which returns 0. [ ] creates an anonymous arrayref [ 0 ]. @{ } dereferences that and puts the contents ( 0 ) into the string. When would you use this idiom? Rarely. Just saying e.g. print "EXIT_SUCCESS is ", EXIT_SUCCESS, ", EXIT_FAILURE is ", EXIT_FAILURE" is just about as clear. Even if you need the whole thing in one scalar, not in a list, either of these is also just about as clear: join "", "EXIT_SUCCESS is ", EXIT_SUCCESS, ", EXIT_FAILURE is ", EXIT_FAILURE" or sprintf "EXIT_SUCCESS is %d, EXIT_FAILURE is %d", EXIT_SUCCESS, EXIT_FAILURE (Just replacing the ,'s with .'s works too, but I don't find that visually distinctive enough; I try to avoid use of multiple .'s.) I occasionally use it to interpolate a "constant", especially where a join or sprintf would otherwise be needed, but avoid it other times. But I sometimes like to put things into posts just in the hope that at least one person is nudged to do some Fine Manual reading. From pdarley at kinesis-cem.com Wed Jan 25 14:09:39 2006 From: pdarley at kinesis-cem.com (Peter Darley) Date: Wed, 25 Jan 2006 14:09:39 -0800 Subject: SPUG: Symbolic references ??? Message-ID: Message Chuck, What you're doing here is setting $lc_table to be a refrence to an anonymous array, rather than using the name in $lc_table to determine where the data goes. You could use an eval: eval("push \@$lc_table, \"rep bla bla bla bla bla\";"); Note: Someone's going to bitch about the parens not doing anything, but they make it easier for me to read, so there! :) Thanks, Peter Darley -----Original Message----- From: spug-list-bounces at pm.org [mailto:spug-list-bounces at pm.org]On Behalf Of Orr, Chuck (NOC) Sent: Wednesday, January 25, 2006 12:50 PM To: spug-list at pm.org Subject: SPUG: Symbolic references ??? Hello, I have a group of 5 arrays, named as follows: my @ofcrte; my @pxrte; my @acrte; my @farte; my @ftrte; I would like to push something on to one of them per iteration of a loop, the pushee determined by a variable named $lc_table. If I read pgs 16 & 17 of the leopard (advanced perl programming) correctly, I should be able to use a symbolic reference to push to the appropriate array depending on the contents of the $lc_table variable. I have turned strict refs off within the loop. here is my push line: push @$lc_table, "rep bla bla bla bla bla"; when I then print the above listed arrays, they have nothing in them. However, if I print "@$lc_table"; within the loop, there are elements in the array. Any suggestions? If anyone can help me and has time to look at a little more code, I would be glad to send it. Thanks for your help, Chuck Orr chuck.orr at cingular.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/spug-list/attachments/20060125/17e285a6/attachment.html From sthoenna at efn.org Wed Jan 25 14:09:43 2006 From: sthoenna at efn.org (Yitzchak Scott-Thoennes) Date: Wed, 25 Jan 2006 14:09:43 -0800 Subject: SPUG: Symbolic references ??? In-Reply-To: References: Message-ID: <20060125220943.GB3168@efn.org> On Wed, Jan 25, 2006 at 12:50:17PM -0800, Orr, Chuck (NOC) wrote: > > > > > Hello, > > I have a group of 5 arrays, named as follows: > > my @ofcrte; > my @pxrte; > my @acrte; > my @farte; > my @ftrte; > > I would like to push something on to one of them per iteration of a > loop, the pushee determined by a variable named $lc_table. > > If I read pgs 16 & 17 of the leopard (advanced perl programming) > correctly, I should be able to use a symbolic reference to push to the > appropriate array depending on the contents of the $lc_table variable. > I have turned strict refs off within the loop. > > here is my push line: > > push @$lc_table, "rep bla bla bla bla bla"; > > when I then print the above listed arrays, they have nothing in them. > However, if I print "@$lc_table"; within the loop, there are elements in > the array. Any suggestions? Symbolic references always find global variables, not lexicals. So, your push is changing the @::ftrte array, etc. That's just one of the reasons they are not such a hot idea. my @ofcrte; my @pxrte; my @acrte; my @farte; my @ftrte; my %foorte = ( ofcrte => \@ofcrte, pxrte => \@pxrte, acrte => \@acrte, farte => \@farte, ftrte => \@ftrte ); ... push @{$foorte{$lc_table}}, ... Better yet, junk the individual arrays altogether and just use a hash of arrays. From krahnj at telus.net Wed Jan 25 14:46:13 2006 From: krahnj at telus.net (John W. Krahn) Date: Wed, 25 Jan 2006 14:46:13 -0800 Subject: SPUG: geting the perl version In-Reply-To: References: Message-ID: <43D7FFB5.2040705@telus.net> Atom Powers wrote: > I want to do this: `/usr/bin/perl -V:version | /usr/bin/cut -d "'" -f > 2` without using pipes or quotes; is that possible? (for some reason > my application isn't executing this correctly) > > That is; I am looking for a simple way to get just the version number > wihout any padding. Something like "5.8.7" or "5.0.6" or whatever. $ perl -e'printf "%vd\n", $^V' 5.8.6 John -- use Perl; program fulfillment From MichaelRWolf at att.net Wed Jan 25 21:53:28 2006 From: MichaelRWolf at att.net (Michael R. Wolf) Date: Wed, 25 Jan 2006 21:53:28 -0800 Subject: SPUG: WSA + MS -> "Best of PDC" Message-ID: I've heard great things about this. It's cheap. It really is the best of the best. You don't have to travel to the multi-day event. You know that I'm a dyed-in-the-wool Open Source bigot, but I've even been tempted to go, learn, meet, report back. It's a big world. I hope folks don't mind posting such a great value in this developer-centered list. Jan. 30: "WSA & Microsoft Present Best of the 2005 PDC" Time: 7:30 a.m. to 5 p.m. Place: Microsoft Conference Center, 16070 NE 36th Way, Building #33, Redmond Cost: Please see event Web site for details. Description: Hear from a handful of architects creating the next generation of Microsoft software as the WSA presents the "Best of the 2005 Microsoft PDC (Professional Developers Conference)." Contact: (206) 448-3033 ext. 103 Web site and registration: www.wsa.org/events/event.asp?EventID=607 -- Michael R. Wolf All mammals learn by playing! MichaelRWolf at att.net From mike206 at gmail.com Thu Jan 26 10:14:17 2006 From: mike206 at gmail.com (mike) Date: Thu, 26 Jan 2006 10:14:17 -0800 Subject: SPUG: odd array ref issue Message-ID: I've totally been pulling my hair out over this and I'm probably missing something stupid here but I figured the SPUG eyes would notice it immediately I have an array ref in $tmp, here is the Data::Dumpage Thu Jan 26 10:00:40 2006 tmp: $VAR1 = [ '102', '104' ]; then I put that into my $params hashref $params->{donor_pk} = $tmp; then I Data::Dump the $params hashref Thu Jan 26 10:00:40 2006 params: $VAR1 = { 'all' => '1', 'Submit' => '1', 'view' => 'donors', 'donor_pk' => 'ARRAY(0x60234)' }; notice the dumper does not traverse into that array, which it usually does with other hashrefs and objects i've created. the ref() function also does not return ARRAY anymore after I stick it into that hash. furthermore, that hash goes into another hash which is obviously not going to do much for me either. this is something i do rather frequently but do not think i've seen this issue before. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/spug-list/attachments/20060126/0be049f9/attachment.html From cmeyer at helvella.org Thu Jan 26 10:20:55 2006 From: cmeyer at helvella.org (Colin Meyer) Date: Thu, 26 Jan 2006 10:20:55 -0800 Subject: SPUG: odd array ref issue In-Reply-To: References: Message-ID: <20060126182055.GH13359@funpox.helvella.org> On Thu, Jan 26, 2006 at 10:14:17AM -0800, mike wrote: > I've totally been pulling my hair out over this and I'm probably missing > something stupid here but I figured the SPUG eyes would notice it > immediately > > > > I have an array ref in $tmp, here is the Data::Dumpage > > Thu Jan 26 10:00:40 2006 tmp: $VAR1 = [ > '102', > '104' > ]; > > then I put that into my $params hashref > > $params->{donor_pk} = $tmp; Are you sure that the line in your code doesn't look something more like: $params->{donor_pk} = "$tmp"; It seems that your array ref is being stringified somewhere. Perhaps including a sample of your actual code will shed more light. -Colin. > > then I Data::Dump the $params hashref > > Thu Jan 26 10:00:40 2006 params: $VAR1 = { > 'all' => '1', > 'Submit' => '1', > 'view' => 'donors', > 'donor_pk' => 'ARRAY(0x60234)' > }; From john.spug at subaykan.com Thu Jan 26 10:49:15 2006 From: john.spug at subaykan.com (John Subaykan) Date: Thu, 26 Jan 2006 13:49:15 -0500 Subject: SPUG: odd array ref issue Message-ID: Looks like cgi does return a hash that stringifies its values: use strict; use warnings; use Data::Dumper; use CGI; my $q = new CGI; my $params = $q->Vars; my $tmp = [ '102', '104' ]; $params->{all} = 1; $params->{view} = "something"; $params->{donor_pk} = $tmp; print Dumper $params; You get: $VAR1 = { 'all' => '1', 'view' => 'something', 'donor_pk' => 'ARRAY(0x81a850c)' }; some relevant detail at: http://search.cpan.org/dist/CGI.pm/CGI.pm scroll down to "Fetching the parameter list as a hash" - John Subaykan ----- Original Message ----- From: mike To: John Subaykan Sent: Thursday, January 26, 2006 10:30 AM Subject: Re: odd array ref issue Hm. Does data dumper indicate if a hash is tied to a class? anyway, I create a new hash and it is not stringified in the data dump. a I created $params from Vars in cgi.pm (does vars return a tied hash?). i was trying to frob some more data into the POST before processing it.. I can do this another way but this ghetto style approach is usually worth a shot On 1/26/06, John Subaykan wrote: Is your $params hashref tied to a class that stringifies values at assignment with its STORE method? How are you creating $params? ----- Original Message ----- From: mike To: members at seattleperl.org Sent: Thursday, January 26, 2006 10:14 AM Subject: SPUG: odd array ref issue I've totally been pulling my hair out over this and I'm probably missing something stupid here but I figured the SPUG eyes would notice it immediately I have an array ref in $tmp, here is the Data::Dumpage Thu Jan 26 10:00:40 2006 tmp: $VAR1 = [ '102', '104' ]; then I put that into my $params hashref $params->{donor_pk} = $tmp; then I Data::Dump the $params hashref Thu Jan 26 10:00:40 2006 params: $VAR1 = { 'all' => '1', 'Submit' => '1', 'view' => 'donors', 'donor_pk' => 'ARRAY(0x60234)' }; notice the dumper does not traverse into that array, which it usually does with other hashrefs and objects i've created. the ref() function also does not return ARRAY anymore after I stick it into that hash. furthermore, that hash goes into another hash which is obviously not going to do much for me either. this is something i do rather frequently but do not think i've seen this issue before. From john.spug at subaykan.com Thu Jan 26 11:00:26 2006 From: john.spug at subaykan.com (John Subaykan) Date: Thu, 26 Jan 2006 14:00:26 -0500 Subject: SPUG: odd array ref issue Message-ID: So.. Before you assign the arrayref to the $params hashref, you can do: untie %$params; or this disgusting hack which I found interesting: my %params2 = %$params; $params = \%params2; # copy the dereferenced hash, then assign it back to $params. From boss at topfunky.com Thu Jan 26 13:08:33 2006 From: boss at topfunky.com (Geoffrey Grosenbach) Date: Thu, 26 Jan 2006 13:08:33 -0800 Subject: SPUG: Small Perl Job In-Reply-To: References: Message-ID: <670CEC4C-C80B-4EFC-938B-30B9DCCA650B@topfunky.com> I need to hand off a project to another developer. It's written in Perl with Text::Template and a simple MVC framework I wrote a few years ago (plus MySQL). http://aptfinder.org It's a non-profit that helps people find low-cost and subsidized housing. Site updates are minimal, but the client has a list of improvements that she would like to have done. Previous to 4 months ago when I last had time to work on the project, I was charging $30/hour and doing about 10 hours a month on it ($300/ month). It would be perfect for someone who wants a small side job, or a college student who wants a job with a minimal time commitment. If anyone is interested in taking this over, shoot me an email. Thanks, Geoffrey Grosenbach boss at topfunky.com ...................................... Website Development | http://topfunky.com Ruby on Rails Blog | http://nubyonrails.com Ruby on Rails Workshops | http://rubyonrailsworkshops.com Ruby on Rails Podcast | http://podcast.rubyonrails.org From rick.croote at philips.com Thu Jan 26 16:24:42 2006 From: rick.croote at philips.com (Rick Croote) Date: Thu, 26 Jan 2006 16:24:42 -0800 Subject: SPUG: odd array ref issue In-Reply-To: <20060126182055.GH13359@funpox.helvella.org> Message-ID: I'm used to seeing stringified Array message only when I have set the variable as such $Data::Dumper::Maxdepth = 1; I use the above often when data items are so large that they take forever or likely to just crash the program. --- Rick Croote Software Engineer Environment and Tools Team Philips Medical Systems Bothell, WA Rick.Croote at Philips.com Phone: 425-487-7834 Colin Meyer Sent by: spug-list-bounces at pm.org 2006-01-26 10:20 AM To mike cc members at seattleperl.org Subject Re: SPUG: odd array ref issue Classification On Thu, Jan 26, 2006 at 10:14:17AM -0800, mike wrote: > I've totally been pulling my hair out over this and I'm probably missing > something stupid here but I figured the SPUG eyes would notice it > immediately > > > > I have an array ref in $tmp, here is the Data::Dumpage > > Thu Jan 26 10:00:40 2006 tmp: $VAR1 = [ > '102', > '104' > ]; > > then I put that into my $params hashref > > $params->{donor_pk} = $tmp; Are you sure that the line in your code doesn't look something more like: $params->{donor_pk} = "$tmp"; It seems that your array ref is being stringified somewhere. Perhaps including a sample of your actual code will shed more light. -Colin. > > then I Data::Dump the $params hashref > > Thu Jan 26 10:00:40 2006 params: $VAR1 = { > 'all' => '1', > 'Submit' => '1', > 'view' => 'donors', > 'donor_pk' => 'ARRAY(0x60234)' > }; _____________________________________________________________ Seattle Perl Users Group Mailing List POST TO: spug-list at pm.org SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list MEETINGS: 3rd Tuesdays WEB PAGE: http://seattleperl.org/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/spug-list/attachments/20060127/0cc13d5f/attachment.html From james at banshee.com Thu Jan 26 17:02:54 2006 From: james at banshee.com (James Moore) Date: Thu, 26 Jan 2006 17:02:54 -0800 Subject: SPUG: AJAX toolkits that play well with Perl? Message-ID: <200601270102.k0R12hBj022101@server2.banshee.com> I'm at Etel (http://conferences.oreillynet.com/etel2006/) right now, and AJAX is coming up a lot. Anyone using any AJAX toolkits that they like? - James From tanwirh at hotmail.com Sat Jan 28 11:58:43 2006 From: tanwirh at hotmail.com (Tanwir Habib) Date: Sat, 28 Jan 2006 19:58:43 +0000 Subject: SPUG: IndexOf in Perl? Message-ID: Hi, I've recently switched from .NET to Perl for my needs in bioinformatics work. Is there a way in Perl to search an array with its value to get its index? like java does with "IndexOf". Thanks in advance. Habib Hon. Research Assistant Dept of Bioinformatics, University of Exeter, Exeter EX44QJ United Kingdom From charles.e.derykus at boeing.com Sat Jan 28 13:46:42 2006 From: charles.e.derykus at boeing.com (DeRykus, Charles E) Date: Sat, 28 Jan 2006 13:46:42 -0800 Subject: SPUG: IndexOf in Perl? Message-ID: > I've recently switched from .NET to Perl for my needs in bioinformatics work. > Is there a way in Perl to search an array with its value to get its index? > like java does with "IndexOf". There are several ways to do this in Perl of course but if you wanted an IndexOf lookalike: sub IndexOf { # pass in value, array reference my ( $value, $arrayref ) = ( shift, shift ); foreach my $i ( 0 .. @$arrayref-1 ) { return $i if $$arrayref[$i] == $value; } } Example: $index = IndexOf( 25, \@array ); * I'm assuming numeric arrays so '==' is used instead of 'eq' * IndexOf returns an undefined value if the value isn't found hth, -- Charles DeRykus From brianwisti at yahoo.com Sat Jan 28 15:16:50 2006 From: brianwisti at yahoo.com (Brian Wisti) Date: Sat, 28 Jan 2006 15:16:50 -0800 (PST) Subject: SPUG: IndexOf in Perl? In-Reply-To: Message-ID: <20060128231650.2774.qmail@web53601.mail.yahoo.com> --- Tanwir Habib wrote: > Hi, > > I've recently switched from .NET to Perl for my needs in > bioinformatics work. > > Is there a way in Perl to search an array with its value to get its > index? like java does with "IndexOf". > You might try the List::Util module. It's core in 5.8. use List::Util qw(first); ... my $index = first { $_ == $test_value } @array; Kind Regards, Brian Wisti http://coolnamehere.com/ __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From david.dyck at fluke.com Sat Jan 28 15:32:40 2006 From: david.dyck at fluke.com (David Dyck) Date: Sat, 28 Jan 2006 15:32:40 -0800 (PST) Subject: SPUG: IndexOf in Perl? In-Reply-To: References: Message-ID: On Sat, 28 Jan 2006 at 11:58 -0800, Tanwir Habib wrote: > I've recently switched from .NET to Perl for my needs in > bioinformatics work. > > Is there a way in Perl to search an array with its value to get its > index? like java does with "IndexOf". Look at List::MoreUtils http://search.cpan.org/dist/List-MoreUtils/lib/List/MoreUtils.pm perl -le 'use List::MoreUtils qw(firstidx); print firstidx { /z/ } ("a" .."z");' 25 firstidx BLOCK LIST first_index BLOCK LIST Returns the index of the first element in LIST for which the criterion in BLOCK is true. Sets $_ for each item in LIST in turn: my @list = (1, 4, 3, 2, 4, 6); printf "item with index %i in list is 4", firstidx { $_ == 4 } @list; __END__ item with index 1 in list is 4 Returns -1 if no such item could be found. first_index is an alias for firstidx. From david.dyck at fluke.com Sat Jan 28 15:35:17 2006 From: david.dyck at fluke.com (David Dyck) Date: Sat, 28 Jan 2006 15:35:17 -0800 (PST) Subject: SPUG: IndexOf in Perl? In-Reply-To: <20060128231650.2774.qmail@web53601.mail.yahoo.com> References: <20060128231650.2774.qmail@web53601.mail.yahoo.com> Message-ID: On Sat, 28 Jan 2006 at 15:16 -0800, Brian Wisti wrote: > You might try the List::Util module. It's core in 5.8. > > use List::Util qw(first); > ... > my $index = first { $_ == $test_value } @array; $index is the element, not the index they were looking for. perl -le ' use List::Util qw(first); print first { /c/ } ('a' .. 'z'); ' c From tanwirh at hotmail.com Sat Jan 28 16:25:31 2006 From: tanwirh at hotmail.com (Tanwir Habib) Date: Sun, 29 Jan 2006 00:25:31 +0000 Subject: SPUG: IndexOf in Perl? In-Reply-To: Message-ID: Many thanks for the reply. I'm not sure where I am wrong but its not working somehow #!/usr/bin/perl -w use strict; use List::Util qw(first); my @array = qw/AA AC AE AF AG CA CC CD DC CB VV YY/; My $index = first {$_ eq 'AF'} @array; print $index; It should print 3 but its printing AF. On 28/1/06 23:35, "David Dyck" wrote: > On Sat, 28 Jan 2006 at 15:16 -0800, Brian Wisti wrote: > >> You might try the List::Util module. It's core in 5.8. >> >> use List::Util qw(first); >> ... >> my $index = first { $_ == $test_value } @array; > > $index is the element, not the index they were looking for. > > perl -le ' use List::Util qw(first); print first { /c/ } ('a' .. 'z'); ' > c > > From tim at consultix-inc.com Sat Jan 28 18:56:28 2006 From: tim at consultix-inc.com (Tim Maher) Date: Sat, 28 Jan 2006 18:56:28 -0800 Subject: SPUG: [OT] Discounted training for List Members Message-ID: <20060129025628.GA27271@jumpy.consultix-inc.com> Fellow Perl Mongrels, As a gesture of *good will* (and /slow sales/), I'll give readers of this list the "EarlyBird discount" (up to $120) on any of the Seattle-area software training classes listed below--including the first three, which are officially no longer available for discounts. Check out the announcement below! -Tim *-------------------------------------------------------------------* | Tim Maher, PhD (206) 781-UNIX (866) DOC-PERL (866) DOC-UNIX | | tim at ( Consultix-Inc, TeachMePerl, or TeachMeUnix ) dot Com | *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-* | 2/14: Linux 2/27: Perl 3/13: Shell 3/16: Utils 4/4: Hashes | *-------------------------------------------------------------------* From: Tim Maher, Consultix Re: Extensive Class Schedule for Feb-Apr in Seattle We've just scheduled the most extensive series of training classes we've ever offered in Seattle--on UNIX, Linux, and Perl topics! What's more, we're also debuting a spanking-new collection of high-speed big-screen student laptops for this set of classes, which can triple-boot Linux, Solaris, and Windoze. Here's the schedule of 12 classes; in 11 weeks! ----------------------------------------------------- Consultix Public Class Schedule, Seattle Feb-Apr 2006 ----------------------------------------------------- TITLE DATES Days UNIX/Linux Fundamentals 2/14-2/17 4 Perl Programming 2/27-3/01 3 Perl Modules, plus CGI 3/02-3/03 1.5 Shell Programming 3/13-3/15 3 UNIX/Linux Utilities 3/16-3/17 2 Minimal Perl 4/3 1 Perl Hashes & Arrays 4/4 1 Intermediate Perl 4/05-4/07 3 Adv. Shell Programming 4/10-4/14 4.5 Minimal Perl 4/24 1 Basic OO Perl 4/25-4/26 2 Int. Pattern Matching 4/27-4/28 1.5 ----------------------------------------------------- CLASS DESCRIPTIONS Brief descriptions of the classes on the current schedule are provided at http://consultix-inc.com/sched.html PRICES AND REGISTRATION Information on the registration process and class prices can be found at http://www.consultix-inc.com/reg.txt On-line registration will open soon. QUESTIONS? Let me know if you have any questions, -Tim Maher P.S. For groups of 3 or more students from the same company, ask about "on-site" classes! ************************************************************ CONSULTIX ON-LINE RESOURCES General Information: http://www.consultix-inc.com Minimal Perl book's web site, for info and ordering: http://manning.com/Maher On-Site Training: http://www.consultix-inc.com/on-site.html Course Listings: Perl, http://TeachMePerl.com/perllist.html UNIX/Shell, http://TeachMeUnix.com/unixlist.html Class Prices and Registration: http://www.consultix-inc.com/reg.txt http://www.consultix-inc.com/cgibin/register.cgi Instructor Evaluations: http://www.consultix-inc.com/evals.html Course Evaluations: http://www.consultix-inc.com/course_evals.html *-------------------------------------------------------------------* | Tim Maher, PhD (206) 781-UNIX (866) DOC-PERL (866) DOC-UNIX | | tim at ( Consultix-Inc, TeachMePerl, or TeachMeUnix ) dot Com | *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-* | Watch for my upcoming book: "Minimal Perl for UNIX/Linux People" | | See MinimalPerl.com for details, ordering, and email-list signup | *-------------------------------------------------------------------* -- *-------------------------------------------------------------------* | Tim Maher, PhD (206) 781-UNIX (866) DOC-PERL (866) DOC-UNIX | | tim at ( Consultix-Inc, TeachMePerl, or TeachMeUnix ) dot Com | *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-* | 2/14: Linux 2/27: Perl 3/13: Shell 3/16: Utils 4/4: Hashes | | Watch for my upcoming book: "Minimal Perl for UNIX/Linux People" | | See MinimalPerl.com for details, ordering, and email-list signup | *-------------------------------------------------------------------* From aaron at activox.com Sun Jan 29 12:11:59 2006 From: aaron at activox.com (aaron salo) Date: Sun, 29 Jan 2006 12:11:59 -0800 Subject: SPUG: IndexOf in Perl? In-Reply-To: References: Message-ID: <43DD218F.5020703@activox.com> Tanwir Habib wrote: >Many thanks for the reply. > >I'm not sure where I am wrong but its not working somehow > Hi Tanwir, At the risk of being overly verbose, since you are new to perlish things, it may be useful to give you a solution that illustrates things in a less obscure manner than just calling a function in something from CPAN. And at the same time we get to use an array, a hash, and a regex. Instead of an obfuscated two liner, I wrote it out longways in the hope this may make it easier to see what's going on and perhaps make modifications to suit your need. Hooray. The snippet below has a couple advantages, first, it uses regex match so it treats everything as strings (side benefit being you don't have to worry about whether to use 'eq' or '=='. It also corrects the potential flaw where there might be multiple matches in your list, if that should occur you get back a list of all of them instead of breaking on the first match. Welcome to perl and I hope you enjoy using it. use strict; my @array = qw/AA AC AE AF AG CA CC CD DC CA FF RR 15 3M CA CB VV YY/; my $matchval = 'CA'; # to get a list of the matches # pass your matching string as the first item # and your list after that my %hits = listMatch($matchval, at array); if (%hits) { foreach(sort {$a <=> $b} keys %hits) { # please note this is NOT the array index # it's the order in the list # subtract 1 to get the array index print qq(item $_ matches $hits{$_}\n); } } else { print qq(sorry, no matches\n); } exit 0; # ====== sub listMatch { my @inbound = @_; my $matchpattern = shift(@inbound); my %outbound; my $itemcount = @inbound; if ($itemcount) { for (my $i=1;$i<$itemcount;$i++) { my $thismember = $inbound[$i-1]; if ($thismember =~ m/^$matchpattern$/) { # print qq(matching $thismember to $matchpattern as item $i\n); $outbound{$i} = $thismember; } } } else { # reserved for error handling, if no items received } return(%outbound); } # end sub listMatch From cos at indeterminate.net Sun Jan 29 18:43:34 2006 From: cos at indeterminate.net (John Costello) Date: Sun, 29 Jan 2006 18:43:34 -0800 (PST) Subject: SPUG: AJAX toolkits that play well with Perl? In-Reply-To: <200601270102.k0R12hBj022101@server2.banshee.com> Message-ID: On Thu, 26 Jan 2006, James Moore wrote: > I'm at Etel (http://conferences.oreillynet.com/etel2006/) right now, and > AJAX is coming up a lot. Anyone using any AJAX toolkits that they like? Catalyst looks interesting. > - James ----- John Costello - cos at indeterminate dot net From rkosai at u.washington.edu Tue Jan 31 23:01:02 2006 From: rkosai at u.washington.edu (Ryan T. Kosai) Date: Tue, 31 Jan 2006 23:01:02 -0800 Subject: SPUG: Security through insecurity... Message-ID: <43E05CAE.1020904@u.washington.edu> Since I use my laptop for all my business, personal, and schoolwork, I end up bringing it with me to an inordinate number of destinations. If it were lost, recovery would be more important to me than absolute security. As such, I thought it would be a good idea to disable the password login and log directly into an unpriveleged account on start up, and write a quick tripwire program for my computer that would run at this time. I'd log into a separate account to do school/business stuff. Initially, I thought it would be best to post IP and tracert (Windows) pipe outputs to a webserver. I thought it would be safer though, to be able to send an e-mail to several destinations, in case my webserver account could be compromised. Now, to send this e-mail, I would have to log into a SMTP relay. This would require a password; which I don't want plaintext or easily recoverable (such as ROT13 or such) in a Perl script. So, in this case, an open SMTP relay seems best. The question is, (a) is this a good idea to use an open SMTP relay? (b) Is there a way to secure a password? I notice this problem logging into mysql servers via Perl too. (c) Besides IP and tracert, any other good information I could grab? No built in mic or anything like that; its a simple laptop. Thanks, -- Ryan T. Kosai, Undergraduate rkosai at u.washington.edu Molecular Biology/Electrical Engr. //students.washington.edu/rkosai