From rdm at cfcl.com Sat Jun 3 12:00:56 2006 From: rdm at cfcl.com (Rich Morin) Date: Sat, 3 Jun 2006 12:00:56 -0700 Subject: [sf-perl] Dim Sum planned for Sunday, June 3 (tomorrow!) Message-ID: Vicki and I haven't done Dim Sum in a while. We hope you can join us! Date: Sunday, June 3 Time: 10:15 am. N.B. - Doors open at 10:30. Please try to arrive by 10:15 OR make sure we know you are coming! We will go in and get a table at 10:30. Location: Hong Kong Flower Lounge (650) 692-6666 51 Millbrae Ave. at El Camino Real Millbrae, CA 3-story pinkish building with a green tile roof underground parking garage, street parking Directions: 2 blocks from Millbrae Caltrain From 101, take "Millbrae Ave" exit west to ECR, cross ECR, pass restaurant and make a U turn at the next street (or park and walk back). From 280, take "Trousdale Ave" exit east to ECR, turn North on ECR and drive about 1/4 mile to Millbrae Ave. Turn left, pass restaurant and make a U turn at the next street (or park and walk back). http://maps.yahoo.com/py/maps.py?BFCat=&Pyt=Tmap&newFL=Use+Address+Below&addr=El+Camino+Real+and+Millbrae+Ave&csz=Millbrae%2C+CA&Country=us&Get%A0Map=Get+Map P.S. For those with vegetarian tendencies, we recognize that Dim Sum is not generally high in veg. content. But this place has greens, mushrooms, and such AND you can order any dish from the regular menu so you ought to be able to find a mixed vegetable plate if you want to be sociable. -- email: rdm at cfcl.com; phone: +1 650-873-7841 http://www.cfcl.com/rdm - my home page, resume, etc. http://www.cfcl.com/Meta - The FreeBSD Browser, Meta Project, etc. http://www.ptf.com/dossier - Prime Time Freeware's DOSSIER series http://www.ptf.com/tdc - Prime Time Freeware's Darwin Collection From rdm at cfcl.com Sat Jun 3 14:08:03 2006 From: rdm at cfcl.com (Rich Morin) Date: Sat, 3 Jun 2006 14:08:03 -0700 Subject: [sf-perl] Dim Sum planned for Sunday, June 4 (tomorrow!) Message-ID: [As was pointed out to me, Sunday is the 4th. Sigh. -r] Vicki and I haven't done Dim Sum in a while. We hope you can join us! Date: Sunday, June 4 Time: 10:15 am. N.B. - Doors open at 10:30. Please try to arrive by 10:15 OR make sure we know you are coming! We will go in and get a table at 10:30. Location: Hong Kong Flower Lounge (650) 692-6666 51 Millbrae Ave. at El Camino Real Millbrae, CA 3-story pinkish building with a green tile roof underground parking garage, street parking Directions: 2 blocks from Millbrae Caltrain From 101, take "Millbrae Ave" exit west to ECR, cross ECR, pass restaurant and make a U turn at the next street (or park and walk back). From 280, take "Trousdale Ave" exit east to ECR, turn North on ECR and drive about 1/4 mile to Millbrae Ave. Turn left, pass restaurant and make a U turn at the next street (or park and walk back). http://maps.yahoo.com/py/maps.py?BFCat=&Pyt=Tmap&newFL=Use+Address+Below&addr=El+Camino+Real+and+Millbrae+Ave&csz=Millbrae%2C+CA&Country=us&Get%A0Map=Get+Map P.S. For those with vegetarian tendencies, we recognize that Dim Sum is not generally high in veg. content. But this place has greens, mushrooms, and such AND you can order any dish from the regular menu so you ought to be able to find a mixed vegetable plate if you want to be sociable. -- email: rdm at cfcl.com; phone: +1 650-873-7841 http://www.cfcl.com/rdm - my home page, resume, etc. http://www.cfcl.com/Meta - The FreeBSD Browser, Meta Project, etc. http://www.ptf.com/dossier - Prime Time Freeware's DOSSIER series http://www.ptf.com/tdc - Prime Time Freeware's Darwin Collection From vlb at cfcl.com Mon Jun 5 14:17:54 2006 From: vlb at cfcl.com (Vicki Brown) Date: Mon, 5 Jun 2006 14:17:54 -0700 Subject: [sf-perl] JOB - PERL Examiner (also Open BSD, Apache) Message-ID: Note that this is not a QA position. This is a need to test the knowledge of a Perl developer. If you have done Perl teaching & testing and are interested, please contact Michael directly at "Michael Bachmann" ==== Begin Original Message Text ===== I hope this finds a person that can assist. My name is Michael Bachmann and I am the IT Manager for the Bay Area Air Quality Management District in San Francisco. I'm looking for somebody that could administer a test for a PERL developer I have in-house. I'm looking for both a written and a practical examination that identify their strong and weak points in regards to PERL development. If you know of anyone that might be qualified or interested - please forward them my information. (I'm also interested in testing them in Open BSD and Apache) Thank you - Michael Bachmann IT Manager BAAQMD (415) 749 - 4720 ==== End Original Message Text ===== -- - Vicki ZZZ zzZ San Francisco Bay Area, CA z |\ _,,,---,,_ Books, Cats, Tech zz /,`.-'`' -. ;-;;,_ http://cfcl.com/vlb |,4- ) )-,_. ,\ ( `'-' http://cfcl.com/vlb/weblog '---''(_/--' `-'\_) http://vlb.typepad.com/commentary/ From extasia at extasia.org Mon Jun 12 11:15:12 2006 From: extasia at extasia.org (David Alban) Date: Mon, 12 Jun 2006 11:15:12 -0700 Subject: [sf-perl] Book(s) for learning oo perl? Message-ID: <4c714a9c0606121115q53b6d113w60b20401e0139628@mail.gmail.com> Greetings, I just looked up Object Oriented Perl by Damien Conway on amazon. It says it's not available. It was also out of stock at another retailer. (It's also, I believe, going on seven years old.) I could buy it used, but before I do that, I wanted to ask, what are folks' opinions on the best books to learn object oriented perl for someone very familiar with perl, but not very familiar with object oriented programming? (I want something in addition to the perl man pages.) Thanks, David -- Live in a world of your own, but always welcome visitors. From andy at petdance.com Mon Jun 12 11:17:57 2006 From: andy at petdance.com (Andy Lester) Date: Mon, 12 Jun 2006 13:17:57 -0500 Subject: [sf-perl] Book(s) for learning oo perl? In-Reply-To: <4c714a9c0606121115q53b6d113w60b20401e0139628@mail.gmail.com> References: <4c714a9c0606121115q53b6d113w60b20401e0139628@mail.gmail.com> Message-ID: On Jun 12, 2006, at 1:15 PM, David Alban wrote: > I just looked up Object Oriented Perl by Damien Conway on amazon. It > says it's not available. It was also out of stock at another > retailer. (It's also, I believe, going on seven years old.) Then find a retailer where it's not out of stock. There is no better book on OO Perl, and it's one of the best computer books ever. -- Andy Lester => andy at petdance.com => www.petdance.com => AIM:petdance From qw at sf.pm.org Mon Jun 12 11:54:10 2006 From: qw at sf.pm.org (Quinn Weaver) Date: Mon, 12 Jun 2006 11:54:10 -0700 Subject: [sf-perl] Book(s) for learning oo perl? In-Reply-To: References: <4c714a9c0606121115q53b6d113w60b20401e0139628@mail.gmail.com> Message-ID: <20060612185410.GA44541@fu.funkspiel.org> On Mon, Jun 12, 2006 at 01:17:57PM -0500, Andy Lester wrote: > > On Jun 12, 2006, at 1:15 PM, David Alban wrote: > > > I just looked up Object Oriented Perl by Damien Conway on amazon. It > > says it's not available. It was also out of stock at another > > retailer. (It's also, I believe, going on seven years old.) > > Then find a retailer where it's not out of stock. > > There is no better book on OO Perl, and it's one of the best computer > books ever. I respectfully disagree. _Object Oriented Perl_ is a good intellectual exercise, I think, but a poor introduction to OO and an even worse primer on OO Perl. Damian 's approach is to enumerate every existing approach to OO, detail its benefits and failings, and then move on to consider a yet better solution. That's great if you want to understand his reasoning, but it means that 90% of the technical detail is throw-away. In fact, the book predates Damian's Class::Std, which is Damian's final word on Perl OO, and which prefigures OO in Perl 6. I think you are much better off learning Class::Std and skipping _Object Oriented Perl_ altogether. What I recommend, then, is Damian's _Perl Best Practices_. It covers Class::Std. It's much more concise (OO is just part of the book). But first... you probably want to pick up a generic primer on OO philosophy, and read it first. That way you can separate the concepts from the implementation, rather than trying to digest both at once. Unfortunately, I don't have any recommendations; all the treatments I've seen are mediocre. One final hint in the same vein: if this is your first time with object orientation, you might consider training up on a language other than Perl. Perl makes OO a little weird, even with--or especially with--the extensive massaging of Class::Std. (That module uses so-called "inside-out objects", which are really a hack to overcome the shortcomings of Perl's scanty built-in OO support. Few other languages use them.) If you go this route, Ruby would be an excellent choice. So would Python. I wouldn't choose Java; it makes life too hard by making you predeclare types and method signatures. I hope this helps. Then, once you've wrapped your head around the OO idea, you have to learn good OO design. Some people grasp it instinctively; some people create terrible mush. Fortunately, it's a learnable skill. Write back! We'll help vet your OO designs. :) -- qw (Quinn Weaver); #President, San Francisco Perl Mongers =for information, visit http://sf.pm.org/weblog =cut From andy at petdance.com Mon Jun 12 11:56:16 2006 From: andy at petdance.com (Andy Lester) Date: Mon, 12 Jun 2006 13:56:16 -0500 Subject: [sf-perl] Book(s) for learning oo perl? In-Reply-To: <20060612185410.GA44541@fu.funkspiel.org> References: <4c714a9c0606121115q53b6d113w60b20401e0139628@mail.gmail.com> <20060612185410.GA44541@fu.funkspiel.org> Message-ID: <4F47D6A1-31D7-472C-A74F-16CC47319299@petdance.com> On Jun 12, 2006, at 1:54 PM, Quinn Weaver wrote: > What I recommend, then, is Damian's _Perl Best Practices_. It covers > Class::Std. It's much more concise (OO is just part of the book). Yeah, but I don't like how that works as far as Perl OO, and is terribly non-standard, and I'm not sure it'll ever get adopted. Prefiguring Perl 6 isn't an advantage, either, in my book. xoa -- Andy Lester => andy at petdance.com => www.petdance.com => AIM:petdance From chris at noncombatant.org Mon Jun 12 12:13:43 2006 From: chris at noncombatant.org (Chris Palmer) Date: Mon, 12 Jun 2006 12:13:43 -0700 Subject: [sf-perl] Book(s) for learning oo perl? In-Reply-To: <4F47D6A1-31D7-472C-A74F-16CC47319299@petdance.com> References: <4c714a9c0606121115q53b6d113w60b20401e0139628@mail.gmail.com> <20060612185410.GA44541@fu.funkspiel.org> <4F47D6A1-31D7-472C-A74F-16CC47319299@petdance.com> Message-ID: <20060612191343.GD28134@nodewarrior.org> Speaking of books, Perl, and OOP, here is a message Mark Jason Dominus just posted to the hop-discuss list. hop-discuss is the discussion list for his excellent book *Higher Order Perl*, which I gleefully and often recommend, even to programmers who don't use Perl. As for OOP itself, I have two additional suggestions: (a) don't over-apply it; and (b) read up on its original applications, such as multi-agent simulations (e.g. the language Simula, and the software suite Swarm from the Santa Fe Institute). ==== Begin Forwarded Message ==== >From: Mark Jason Dominus To: hop-discuss at plover.com Date: Mon, 12 Jun 2006 14:56:38 -0400 Subject: Closures as destructors and cleanup objects I was writing a class today that represents a flat-file database; among the state inside the object are a filehandle and a record-number counter. The object supports a ->nextrec method that reads the next record from the filehandle, and updates the current record number inside the object. I wanted to support certain methods that would need to save the current position of the filehandle and the current record umber, seek around in the file, and then put the object back the way it was, like this: # save position my $pos = tell $self->{fh}; my $recno = $self->{record_number}; # do stuff that might mess up the filehandle ... # restore position seek $self->{fh}, 0, $pos; $self->{record_number} = $recno; But of course the save-and-restore should be a method: my $position = $self->save_position; # do stuff that might mess up the filehandle ... $self->restore_position($position); We can get a simpler interface by saying that the $position object will restore the position itself when it goes out of scope: { my $position = $self->save_position; # do stuff that might mess up the filehandle ... } # position rewstored automatically The way we normally do this in Perl is to have $position be an object whose DESTROY method performs the restoration. My first cut at this looked like this: sub save_position { my $self = shift; PositionSaver->new($self->{fh}, \($self->{record_number})); } package PositionSaver; sub new { my ($class, $fh, $recno_ref) = @_; my $self = [$fh, tell $fh, $recno_ref, $$recno_ref]; bless $self => $class; } sub DESTROY { my $self = shift; my ($fh, $fh_pos, $recno_ref, $recno) = @$self; seek $fh, 0, $fh_pos; $$recno_ref = $recno; } But instead, I decided to make the PositionSaver object a closure, one which subroutine that performs the appropriate cleanup actions when it is invoked. Its DESTROY method just invokes it: package PositionSaver; sub new { my ($class, $fh, $recno_ref) = @_; my $fh_pos = tell $fh; my $recno = $$recno_ref; my $self = sub { seek $fh, 0, $fh_pos; $$recno_ref = $recno; }; bless $self => $class; } sub DESTROY { my $self = shift; $self->(); } I thought this was simpler, but now that I see them side by side, I'm not sure why I thought so. I do like that the creation of the object and the destruction instructions are all in one place. I've also seen this technique used in Damian Conway's Hook::LexWrap module. It seems simple and general, but I'm not sure it's really worth doing. Any thoughts about possible benefits or drawbacks that I've missed? ==== End Forwarded Message ==== -- http://www.noncombatant.org/ http://www.boshuda.com/ From david at fetter.org Mon Jun 12 12:25:25 2006 From: david at fetter.org (David Fetter) Date: Mon, 12 Jun 2006 12:25:25 -0700 Subject: [sf-perl] Book(s) for learning oo perl? In-Reply-To: <4c714a9c0606121115q53b6d113w60b20401e0139628@mail.gmail.com> References: <4c714a9c0606121115q53b6d113w60b20401e0139628@mail.gmail.com> Message-ID: <20060612192525.GA13908@fetter.org> On Mon, Jun 12, 2006 at 11:15:12AM -0700, David Alban wrote: > Greetings, > > I just looked up Object Oriented Perl by Damien Conway on amazon. > It says it's not available. It was also out of stock at another > retailer. (It's also, I believe, going on seven years old.) Although Damien is a brilliant guy, about half the book had me screaming, "just use an RDBMS and stop [making love] around with this ridiculous [hemipygian] [taurine f??ces]!" I've never been so tempted to throw a book in the garbage as I was by this thing. In other words, you're probably better off not being able to get it. Damien's later book "Perl Best Practices" is definitely good for your bookshelf. > I could buy it used, but before I do that, I wanted to ask, what are > folks' opinions on the best books to learn object oriented perl for > someone very familiar with perl, but not very familiar with object > oriented programming? (I want something in addition to the perl man > pages.) You might want to check out Randal Schwartz's "Learning Perl Objects, References and Modules" from O'Reilly along with (for more OO fun) Kent Beck's "Smalltalk Patterns: Best Practices." :) Cheers, D -- David Fetter http://fetter.org/ phone: +1 415 235 3778 AIM: dfetter666 Skype: davidfetter Remember to vote! From george at metaart.org Mon Jun 12 12:44:11 2006 From: george at metaart.org (George Woolley) Date: Mon, 12 Jun 2006 12:44:11 -0700 Subject: [sf-perl] Book(s) for learning oo perl? In-Reply-To: References: <4c714a9c0606121115q53b6d113w60b20401e0139628@mail.gmail.com> Message-ID: <200606121244.11761.george@metaart.org> On Monday 12 June 2006 11:17, Andy Lester wrote: > On Jun 12, 2006, at 1:15 PM, David Alban wrote: > > I just looked up Object Oriented Perl by Damien Conway on amazon. It > > says it's not available. It was also out of stock at another > > retailer. (It's also, I believe, going on seven years old.) > > Then find a retailer where it's not out of stock. > > There is no better book on OO Perl, and it's one of the best computer > books ever. > > -- > Andy Lester => andy at petdance.com => www.petdance.com => AIM:petdance ========== David, Looking at the publisher's page for the book, I see two interesting things about availability: * a notation saying "Out of stock (?)" * a PDF ebook for $21.50 I've emailed the publishers asking about both. I'll let you know what there response is. George From extasia at extasia.org Mon Jun 12 13:17:12 2006 From: extasia at extasia.org (David Alban) Date: Mon, 12 Jun 2006 13:17:12 -0700 Subject: [sf-perl] Book(s) for learning oo perl? In-Reply-To: <20060612200916.GB44541@fu.funkspiel.org> References: <4c714a9c0606121115q53b6d113w60b20401e0139628@mail.gmail.com> <20060612185410.GA44541@fu.funkspiel.org> <4c714a9c0606121205y62697cc3ub1fdd051bb9e842a@mail.gmail.com> <20060612200916.GB44541@fu.funkspiel.org> Message-ID: <4c714a9c0606121317w3fc8a910wb94a2335568976d0@mail.gmail.com> Again, thanks. ---------- Forwarded message ---------- From: Quinn Weaver Date: Jun 12, 2006 1:09 PM Subject: Re: [sf-perl] Book(s) for learning oo perl? To: David Alban On Mon, Jun 12, 2006 at 12:05:17PM -0700, David Alban wrote: > Thanks very much for your response, Quinn. Glad to be helpful. :) Do you mind if I forward this to the list? I think it could be useful to others. > I'm a tools guy with a sysadmin background, not an application > programmer. Given that, would you recommend ruby over python or vice > versa? I think Python is more often used for sysadmin-y tasks, while Ruby is used for software engineering in the large (especially for Rails apps). Python is a fine choice. Just keep these points in mind: 1. Python does not have encapsulation. This means that you can reach into a Python class and alter its variables directly, rather than being constrained to call methods. Some people really hate this, but, to be honest, I've never felt it's a big deal. It's just one of those "well, then don't do that" situations. Perl has no single OO technique. Most don't support encapsulation, but a few (such as Class::Std) do. Most OO texts you read harp on encapsulation a lot, as it's a central part of the OO dogma. Just be aware that you don't get it in Python, or in Perl (unless you use Class::Std). 2. It follows from 1 that Python does not offer a choice among public, private, and protected inheritance. All inheritance is public. In the Perl world, if you use Class::Std, all inheritance is private. If you instead use the typical Perl "blessed hash" technique, all inheritance is public, as in Python. If you don't understand what all this means, don't worry about it. Just be aware that this part of OO philosophy, should you read about it in an OO book, doesn't apply to Python. In fact, I would just skip such a section. (It's mostly for C++ people.) Later, when you read _Perl Best Practices_, you will see Damian makes a compelling argument that all inheritance should be private. If you truly believe in encapsulation, then you should buy this argument. 3. Python has a weird, bolted-on syntax for declaring class methods (a.k.a. static methods). However, class methods are a seldom-used OO feature, so this is not a big deal either. 4. Python has weak support for multiple inheritance. Perl, if you use blessed hashes, has weak support for multiple inheritance. Perl, if you use Class::Std, has strong support for multiple inheritance. My recommendation is to avoid multiple inheritance altogether unless you find that you really need it. That is, wait till you're actually thinking in OO terms and writing OO programs, and then, if you find yourself wishing that a certain class could inherit from two base classes, go back to the books. Best, -- qw (Quinn Weaver); #President, San Francisco Perl Mongers =for information, visit http://sf.pm.org/weblog =cut -- Live in a world of your own, but always welcome visitors. From doom at kzsu.stanford.edu Mon Jun 12 13:18:08 2006 From: doom at kzsu.stanford.edu (Joseph Brenner) Date: Mon, 12 Jun 2006 13:18:08 -0700 Subject: [sf-perl] Book(s) for learning oo perl? In-Reply-To: References: <4c714a9c0606121115q53b6d113w60b20401e0139628@mail.gmail.com> Message-ID: <200606122018.k5CKI8T03908@mail0.rawbw.com> Andy Lester wrote: > David Alban wrote: > > > I just looked up Object Oriented Perl by Damien Conway on amazon. It > > says it's not available. It was also out of stock at another > > retailer. (It's also, I believe, going on seven years old.) > > Then find a retailer where it's not out of stock. > > There is no better book on OO Perl, and it's one of the best computer > books ever. Stacey's web site says that they've got it on the shelves: http://staceys.booksense.com/NASApp/store/Product?s=showproduct&isbn=1884777791 They also have Conway's "Best Practices" book: http://staceys.booksense.com/NASApp/store/Product?s=showproduct&isbn=0596001738 "Object Oriented Perl" is indeed a really good book, but it is true that it could use some revision. If you look in "Best Practices", you'll see that he's now endorsing "inside-out" objects, which you won't find discussed in "Object Oriented Perl". Of course, while you're likely to see more of the "inside-out" style in the future, hash-based objects are still the consensus choice, so "Object Oriented Perl" is far from worthless. I'd say: read it first, and use "Best Practices" as a supplement. Stacey's is a large bookstore with a good selection of technical books located on Market Street, near 2nd Street. It's a good place, though the hours are a little limited (closes by 7pm most days): http://staceys.booksense.com/NASApp/store/IndexJsp?s=storehours From Peter.Loo at source.wolterskluwer.com Tue Jun 13 10:36:32 2006 From: Peter.Loo at source.wolterskluwer.com (Loo, Peter # PHX) Date: Tue, 13 Jun 2006 10:36:32 -0700 Subject: [sf-perl] Perl DBI => named pipe => sqlldr => Oracle table Message-ID: <8E3D502A002DA04FADBDED4CB4D94D3A016D5C1D@phxmail02.phx.ndchealth.com> Hello All, I have the need to spawn two processes within Perl and was wondering if someone can show me the way. One process open() a named pipe and the other runs "sqlldr user/pass at database control=controlfile.ctl etc...". The problem I am having is, when I attempt to "open(NP, "> $namedPipe")" before executing sqlldr, the program hangs at "open()" so I can't continue with the program to execute sqlldr process. If I start sqlldr first, then open(), sqlldr does not read in the data from the open(). Here is my test program: $pipeFile = "/tmp/$d_tblName"; unless (-p $pipeFile) { print "$pipeFile does not exist.\n"; unless (mkfifo($pipeFile, 0777)) { print "Can't mknod $pipeFile: $!\n"; exit; } } ######################################################################## ##### # COMMENTS: Connect to the source database and prepare the SQL statement to # # start fetching the data to send to the named pipe. # ######################################################################## ##### $s_dbh = sub_connect($s_dbDriver, $INSTANCE, $DBUSER, $DBPASS); $s_dbh->{RowCacheSize} = 500; ($stmtType, $s_sqlString) = sub_readSQLFile(qq{$SQLDIR/$SQL}); $s_sth = sub_prepare($s_dbDriver, $s_dbh, qq{$s_sqlString}); $s_sth = sub_execute($s_dbDriver, $s_dbh, $s_sth); $cnt = 0; ######################################################################## ####### # COMMENTS: Open the named pipe file and start writing to it with the fetched # # data from the source database. # ######################################################################## ####### print STDERR "Opening $pipeFile file to begin writing data.\n"; open (FIFO, "> $pipeFile") or die "$!\n"; <================= It hangs right here. print STDERR "Entering while loop to fetch the source data.\n"; while ($row = $s_sth->fetchrow_arrayref()) { die "Pipe file disappeared.\n" unless -p $pipeFile; #printf(STDERR "%s\n", join($delim, @$row)) if ($DEBUG); printf(FIFO "%s\n", join($delim, @$row)); $cnt++; } print STDERR "We are done with while loop. Closing named pipe.\n"; close(FIFO); print "Removing named pipe: $pipeFile\n"; print "Unable to delete $pipeFile.\n" unless (unlink($pipeFile)); So my question is, is there a way to force Perl to continue after the open() statement so that I can execute "sqlldr" statement to start receiving data from the named pipe? Thanks in advance. Sincerely, Peter -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/sanfrancisco-pm/attachments/20060613/658469df/attachment.html From qw at sf.pm.org Tue Jun 13 13:07:22 2006 From: qw at sf.pm.org (Quinn Weaver) Date: Tue, 13 Jun 2006 13:07:22 -0700 Subject: [sf-perl] Perl DBI => named pipe => sqlldr => Oracle table In-Reply-To: <8E3D502A002DA04FADBDED4CB4D94D3A016D5C1D@phxmail02.phx.ndchealth.com> References: <8E3D502A002DA04FADBDED4CB4D94D3A016D5C1D@phxmail02.phx.ndchealth.com> Message-ID: <20060613200722.GA53641@fu.funkspiel.org> On Tue, Jun 13, 2006 at 10:36:32AM -0700, Loo, Peter # PHX wrote: > Hello All, > > I have the need to spawn two processes within Perl and was wondering if > someone can show me the way. > > One process open() a named pipe and the other runs "sqlldr > user/pass at database > control=controlfile.ctl etc...". Hi, I have some ideas about what might be wrong, but before we repair your wheel, why don't we see what others people have invented? ;) http://search.cpan.org/search?query=sqlldr&mode=all That page shows three recently updated CPAN modules, each expressly designed to speak to sqlldr. I would go with one of those. They're pretty much guaranteed to be better-tested and more robust than your recently written code. And you don't have to maintain them! Man, I love CPAN. ;) -- qw (Quinn Weaver); #President, San Francisco Perl Mongers =for information, visit http://sf.pm.org/weblog =cut From david at fetter.org Tue Jun 13 13:42:22 2006 From: david at fetter.org (David Fetter) Date: Tue, 13 Jun 2006 13:42:22 -0700 Subject: [sf-perl] Perl DBI => named pipe => sqlldr => Oracle table In-Reply-To: <8E3D502A002DA04FADBDED4CB4D94D3A016D5C1D@phxmail02.phx.ndchealth.com> References: <8E3D502A002DA04FADBDED4CB4D94D3A016D5C1D@phxmail02.phx.ndchealth.com> Message-ID: <20060613204221.GD18287@fetter.org> On Tue, Jun 13, 2006 at 10:36:32AM -0700, Loo, Peter # PHX wrote: > Hello All, > > I have the need to spawn two processes within Perl and was wondering > if someone can show me the way. I think you're overthinking this. Make a control file that looks something like this: LOAD DATA INFILE "-" INTO TABLE legacy_system FIELDS TERMINATED BY "Ahnold Governator" OPTIONALLY ENCLOSED BY '"' INTO TABLE smells_like_teen_spirit (here, we, are, now, entertain, us) in it, then use a standard pipe open like this: open($sqlldr, '|sqlldr scott/tiger at omgwtf.i.am.so.glad.i.do.not.use.oracle.any.more.com control=your.ctl') or die "Can't open SQL*Loader. Use PostgreSQL instead ;)"; and start print()ing to $sqlldr instead of STDOUT. When you're done, close $sqlldr, and you're good to go[1]. HTH :) Cheers, D [1] Well, as good as you can be and still use a legacy system like Oracle ;) -- David Fetter http://fetter.org/ phone: +1 415 235 3778 AIM: dfetter666 Skype: davidfetter Remember to vote! From Peter.Loo at source.wolterskluwer.com Tue Jun 13 15:34:40 2006 From: Peter.Loo at source.wolterskluwer.com (Loo, Peter # PHX) Date: Tue, 13 Jun 2006 15:34:40 -0700 Subject: [sf-perl] Perl DBI => named pipe => sqlldr => Oracle table Message-ID: <8E3D502A002DA04FADBDED4CB4D94D3A016D5E96@phxmail02.phx.ndchealth.com> Hi, Yes, I am aware of those modules listed at the link below. In fact, I have Oracle::Sqlldr loaded on our test environment. I was unable to get this module to work due to a problem with sqlldr not being able to DESCRIBE the destination table. I was working with Andrew McGregor and was still working on this matter when I stumbled over the possible culprit. I am looking into it now. On the thread below, please go ahead and close it out as I have found a resolution. Thanks for all your help. Peter -----Original Message----- From: sanfrancisco-pm-bounces+peter.loo=source.wolterskluwer.com at pm.org [mailto:sanfrancisco-pm-bounces+peter.loo=source.wolterskluwer.com at pm.or g] On Behalf Of Quinn Weaver Sent: Tuesday, June 13, 2006 1:07 PM To: San Francisco Perl Mongers User Group Subject: Re: [sf-perl] Perl DBI => named pipe => sqlldr => Oracle table On Tue, Jun 13, 2006 at 10:36:32AM -0700, Loo, Peter # PHX wrote: > Hello All, > > I have the need to spawn two processes within Perl and was wondering > if someone can show me the way. > > One process open() a named pipe and the other runs "sqlldr > user/pass at database > control=controlfile.ctl etc...". Hi, I have some ideas about what might be wrong, but before we repair your wheel, why don't we see what others people have invented? ;) http://search.cpan.org/search?query=sqlldr&mode=all That page shows three recently updated CPAN modules, each expressly designed to speak to sqlldr. I would go with one of those. They're pretty much guaranteed to be better-tested and more robust than your recently written code. And you don't have to maintain them! Man, I love CPAN. ;) -- qw (Quinn Weaver); #President, San Francisco Perl Mongers =for information, visit http://sf.pm.org/weblog =cut _______________________________________________ SanFrancisco-pm mailing list SanFrancisco-pm at pm.org http://mail.pm.org/mailman/listinfo/sanfrancisco-pm This E-mail message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply E-mail, and destroy all copies of the original message. From Peter.Loo at source.wolterskluwer.com Tue Jun 13 15:35:05 2006 From: Peter.Loo at source.wolterskluwer.com (Loo, Peter # PHX) Date: Tue, 13 Jun 2006 15:35:05 -0700 Subject: [sf-perl] Perl DBI => named pipe => sqlldr => Oracle table Message-ID: <8E3D502A002DA04FADBDED4CB4D94D3A016D5E99@phxmail02.phx.ndchealth.com> Thanks a bunch David. Excellent advise. Peter -----Original Message----- From: sanfrancisco-pm-bounces+peter.loo=source.wolterskluwer.com at pm.org [mailto:sanfrancisco-pm-bounces+peter.loo=source.wolterskluwer.com at pm.or g] On Behalf Of David Fetter Sent: Tuesday, June 13, 2006 1:42 PM To: San Francisco Perl Mongers User Group Subject: Re: [sf-perl] Perl DBI => named pipe => sqlldr => Oracle table On Tue, Jun 13, 2006 at 10:36:32AM -0700, Loo, Peter # PHX wrote: > Hello All, > > I have the need to spawn two processes within Perl and was wondering > if someone can show me the way. I think you're overthinking this. Make a control file that looks something like this: LOAD DATA INFILE "-" INTO TABLE legacy_system FIELDS TERMINATED BY "Ahnold Governator" OPTIONALLY ENCLOSED BY '"' INTO TABLE smells_like_teen_spirit (here, we, are, now, entertain, us) in it, then use a standard pipe open like this: open($sqlldr, '|sqlldr scott/tiger at omgwtf.i.am.so.glad.i.do.not.use.oracle.any.more.com control=your.ctl') or die "Can't open SQL*Loader. Use PostgreSQL instead ;)"; and start print()ing to $sqlldr instead of STDOUT. When you're done, close $sqlldr, and you're good to go[1]. HTH :) Cheers, D [1] Well, as good as you can be and still use a legacy system like Oracle ;) -- David Fetter http://fetter.org/ phone: +1 415 235 3778 AIM: dfetter666 Skype: davidfetter Remember to vote! _______________________________________________ SanFrancisco-pm mailing list SanFrancisco-pm at pm.org http://mail.pm.org/mailman/listinfo/sanfrancisco-pm This E-mail message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply E-mail, and destroy all copies of the original message. From rdm at cfcl.com Sat Jun 17 15:37:58 2006 From: rdm at cfcl.com (Rich Morin) Date: Sat, 17 Jun 2006 15:37:58 -0700 Subject: [sf-perl] The Internet Helpdesk Message-ID: This is ROTFL, and very well done... Studio version: http://media.revver.com/broadcast/4036/video.mov/1722 "Live" Version: http://media.revver.com/broadcast/2922/video.mov/1722 Courtesy of: Three dead trolls in a baggie http://www.deadtroll.com/ -r -- http://www.cfcl.com/rdm Rich Morin http://www.cfcl.com/rdm/resume rdm at cfcl.com http://www.cfcl.com/rdm/weblog +1 650-873-7841 Technical editing and writing, programming, and web development From rdm at cfcl.com Sun Jun 25 08:36:00 2006 From: rdm at cfcl.com (Rich Morin) Date: Sun, 25 Jun 2006 08:36:00 -0700 Subject: [sf-perl] BASS reminder Message-ID: Although it looks like there will be no SFPUG meeting for June, the Beer & Scripting SIG (http://www.cfcl.com/rdm/bass) will convene (as usual) on Wed., 6/28. Be there or be elsewhere! -r P.S. I maintain a list of scripting-related groups: SF Bay Area Scripting Groups http://www.cfcl.com/rdm/bass/groups.php Pointers to any missing groups would be welcomed! -- http://www.cfcl.com/rdm Rich Morin http://www.cfcl.com/rdm/resume rdm at cfcl.com http://www.cfcl.com/rdm/weblog +1 650-873-7841 Technical editing and writing, programming, and web development From rdm at cfcl.com Sun Jun 25 10:07:38 2006 From: rdm at cfcl.com (Rich Morin) Date: Sun, 25 Jun 2006 10:07:38 -0700 Subject: [sf-perl] Fireworks, July 3rd. Message-ID: Every year, Stanford hosts a fireworks show and concert on July 3rd. If you happen to like the music they have on offer (Preservation Hall Jazz Band), get tickets and attend: http://livelyarts.stanford.edu/month.php?month=07 Otherwise, join us and the other fireworks freeloaders. The fireworks are set off on Memorial Way, near the corner of Galvez St. The freeloaders hang out on the curb of Galvez, starting at the Serra St. intersection. If you get there by 8 pm, you'll have time to find a spot, have a picnic, etc. -r P.S. If you want to coordinate with us, get in touch... -- http://www.cfcl.com/rdm Rich Morin http://www.cfcl.com/rdm/resume rdm at cfcl.com http://www.cfcl.com/rdm/weblog +1 650-873-7841 Technical editing and writing, programming, and web development From extasia at extasia.org Tue Jun 27 11:08:12 2006 From: extasia at extasia.org (David Alban) Date: Tue, 27 Jun 2006 11:08:12 -0700 Subject: [sf-perl] Technical debt Message-ID: <4c714a9c0606271108x7c492853g22a0fd24bee284a8@mail.gmail.com> This was posted to london.pm. It's quite interesting. http://petdance.com/perl/technical-debt/ -- Live in a world of your own, but always welcome visitors. From david at fetter.org Tue Jun 27 11:53:36 2006 From: david at fetter.org (David Fetter) Date: Tue, 27 Jun 2006 11:53:36 -0700 Subject: [sf-perl] Technical debt In-Reply-To: <4c714a9c0606271108x7c492853g22a0fd24bee284a8@mail.gmail.com> References: <4c714a9c0606271108x7c492853g22a0fd24bee284a8@mail.gmail.com> Message-ID: <20060627185336.GE19727@fetter.org> On Tue, Jun 27, 2006 at 11:08:12AM -0700, David Alban wrote: > This was posted to london.pm. It's quite interesting. > > http://petdance.com/perl/technical-debt/ > The stuff one directory up is pretty nice too. Pet peeve: in the above presentation, he's using pictures with links instead of S5 or PDF. Cheers, D -- David Fetter http://fetter.org/ phone: +1 415 235 3778 AIM: dfetter666 Skype: davidfetter Remember to vote! From andy at petdance.com Tue Jun 27 12:12:28 2006 From: andy at petdance.com (Andy Lester) Date: Tue, 27 Jun 2006 14:12:28 -0500 Subject: [sf-perl] Technical debt In-Reply-To: <4c714a9c0606271108x7c492853g22a0fd24bee284a8@mail.gmail.com> References: <4c714a9c0606271108x7c492853g22a0fd24bee284a8@mail.gmail.com> Message-ID: <20060627191228.GB23978@petdance.com> On Tue, Jun 27, 2006 at 11:08:12AM -0700, David Alban (extasia at extasia.org) wrote: > This was posted to london.pm. It's quite interesting. > > http://petdance.com/perl/technical-debt/ Would be glad to come out there and give the talk to SF.pm some time, too. xoxo, Andy -- Andy Lester => andy at petdance.com => www.petdance.com => AIM:petdance From andy at petdance.com Tue Jun 27 12:16:01 2006 From: andy at petdance.com (Andy Lester) Date: Tue, 27 Jun 2006 14:16:01 -0500 Subject: [sf-perl] Technical debt In-Reply-To: <20060627185336.GE19727@fetter.org> References: <4c714a9c0606271108x7c492853g22a0fd24bee284a8@mail.gmail.com> <20060627185336.GE19727@fetter.org> Message-ID: <20060627191601.GC23978@petdance.com> On Tue, Jun 27, 2006 at 11:53:36AM -0700, David Fetter (david at fetter.org) wrote: > The stuff one directory up is pretty nice too. Pet peeve: in the > above presentation, he's using pictures with links instead of S5 > or PDF. "This free stuff is not to my liking! Darn him putting his work on the web where I can read it!" xoxo, Andy the gift horse -- Andy Lester => andy at petdance.com => www.petdance.com => AIM:petdance From david at fetter.org Tue Jun 27 13:03:47 2006 From: david at fetter.org (David Fetter) Date: Tue, 27 Jun 2006 13:03:47 -0700 Subject: [sf-perl] Technical debt In-Reply-To: <20060627191601.GC23978@petdance.com> References: <4c714a9c0606271108x7c492853g22a0fd24bee284a8@mail.gmail.com> <20060627185336.GE19727@fetter.org> <20060627191601.GC23978@petdance.com> Message-ID: <20060627200347.GF19727@fetter.org> On Tue, Jun 27, 2006 at 02:16:01PM -0500, Andy Lester wrote: > On Tue, Jun 27, 2006 at 11:53:36AM -0700, David Fetter (david at fetter.org) wrote: > > The stuff one directory up is pretty nice too. Pet peeve: in the > > above presentation, he's using pictures with links instead of S5 > > or PDF. > > "This free stuff is not to my liking! Darn him putting his work on the > web where I can read it!" > > xoxo, > Andy the gift horse D'oh! Oh, well. I put up my slides, and I get an occasional complaint, too ;) Cheers, D (a horse with a growing gift) -- David Fetter http://fetter.org/ phone: +1 415 235 3778 AIM: dfetter666 Skype: davidfetter Remember to vote! From danlyke at flutterby.com Tue Jun 27 14:23:38 2006 From: danlyke at flutterby.com (Dan Lyke) Date: Tue, 27 Jun 2006 14:23:38 -0700 Subject: [sf-perl] Technical debt In-Reply-To: <20060627185336.GE19727@fetter.org> References: <4c714a9c0606271108x7c492853g22a0fd24bee284a8@mail.gmail.com> <20060627185336.GE19727@fetter.org> Message-ID: On Tue, 27 Jun 2006 11:53:36 -0700, David Fetter wrote: > The stuff one directory up is pretty nice too. Pet peeve: in the > above presentation, he's using pictures with links instead of S5 > or PDF. Different strokes, I suppose. I far prefer pictures and text with links to anything involving JavaScript[1], and I loathe PDF pretty much across the board[2]. CSS is fine, as I rarely use Windows or IE. Dan [1] which I often turn off to make various web applications more user friendly, the number of buggy JavaScript forms validators far outnumbers the few cases in which JavaScript forms validation is actually helpful. [2] The computer is not paper, and for paper PostScript works fine. From Peter.Loo at source.wolterskluwer.com Wed Jun 28 09:19:15 2006 From: Peter.Loo at source.wolterskluwer.com (Loo, Peter # PHX) Date: Wed, 28 Jun 2006 09:19:15 -0700 Subject: [sf-perl] Quick question on regular expression and substitution Message-ID: <8E3D502A002DA04FADBDED4CB4D94D3A018A12D9@phxmail02.phx.ndchealth.com> Hi All, Would some one know of a one liner that would replace the third occurrence of a substring within a string? For example: $string = "?, ?, ?, ?"; I want to replace the third occurrence of "?" with "to_date(?, 'YYYY-MM-DD HH24:MI:SS')". Thanks in advance. Peter -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/sanfrancisco-pm/attachments/20060628/16dd24fd/attachment.html From david at fetter.org Wed Jun 28 10:01:28 2006 From: david at fetter.org (David Fetter) Date: Wed, 28 Jun 2006 10:01:28 -0700 Subject: [sf-perl] Quick question on regular expression and substitution In-Reply-To: <8E3D502A002DA04FADBDED4CB4D94D3A018A12D9@phxmail02.phx.ndchealth.com> References: <8E3D502A002DA04FADBDED4CB4D94D3A018A12D9@phxmail02.phx.ndchealth.com> Message-ID: <20060628170128.GF1834@fetter.org> On Wed, Jun 28, 2006 at 09:19:15AM -0700, Loo, Peter # PHX wrote: > Hi All, > > Would some one know of a one liner that would replace the third > occurrence of a substring within a string? For example: > > $string = "?, ?, ?, ?"; > > I want to replace the third occurrence of "?" with "to_date(?, > 'YYYY-MM-DD HH24:MI:SS')". > > Thanks in advance. > > Peter Peter, Given the high wackiness of regexes, I'd do something like: $old = '(?, ?, ?, ?)'; # So you're covered on just exactly which clause. $new = q{?, ?, to_date(?, 'YYYY-MM-DD HH24:MI:SS'), ?'}; $query =~ s/$old/$new/; I know it's brute force, but the code is easy to understand later. :) Cheers, D -- David Fetter http://fetter.org/ phone: +1 415 235 3778 AIM: dfetter666 Skype: davidfetter Remember to vote! From david at fetter.org Wed Jun 28 10:04:39 2006 From: david at fetter.org (David Fetter) Date: Wed, 28 Jun 2006 10:04:39 -0700 Subject: [sf-perl] Quick question on regular expression and substitution In-Reply-To: <20060628170128.GF1834@fetter.org> References: <8E3D502A002DA04FADBDED4CB4D94D3A018A12D9@phxmail02.phx.ndchealth.com> <20060628170128.GF1834@fetter.org> Message-ID: <20060628170439.GG1834@fetter.org> On Wed, Jun 28, 2006 at 10:01:28AM -0700, David Fetter wrote: > On Wed, Jun 28, 2006 at 09:19:15AM -0700, Loo, Peter # PHX wrote: > > Hi All, > > > > Would some one know of a one liner that would replace the third > > occurrence of a substring within a string? For example: > > > > $string = "?, ?, ?, ?"; > > > > I want to replace the third occurrence of "?" with "to_date(?, > > 'YYYY-MM-DD HH24:MI:SS')". > > > > Thanks in advance. > > > > Peter > > Peter, > > Given the high wackiness of regexes, I'd do something like: > > $old = '(?, ?, ?, ?)'; # So you're covered on just exactly which clause. > $new = q{?, ?, to_date(?, 'YYYY-MM-DD HH24:MI:SS'), ?'}; Oops. That should read: $new = q{(?, ?, to_date(?, 'YYYY-MM-DD HH24:MI:SS'), ?)}; Cheers, D -- David Fetter http://fetter.org/ phone: +1 415 235 3778 AIM: dfetter666 Skype: davidfetter Remember to vote! From Peter.Loo at source.wolterskluwer.com Wed Jun 28 10:05:11 2006 From: Peter.Loo at source.wolterskluwer.com (Loo, Peter # PHX) Date: Wed, 28 Jun 2006 10:05:11 -0700 Subject: [sf-perl] Quick question on regular expression and substitution Message-ID: <8E3D502A002DA04FADBDED4CB4D94D3A018A1343@phxmail02.phx.ndchealth.com> Hi David, The problem is I won't know what position I need to change. It is all dependent on the query. For example: Another query might return 10 ?s. And within the 10 ?s, I might need to change the 7th "?". Does that make sense? Peter -----Original Message----- From: sanfrancisco-pm-bounces+peter.loo=source.wolterskluwer.com at pm.org [mailto:sanfrancisco-pm-bounces+peter.loo=source.wolterskluwer.com at pm.or g] On Behalf Of David Fetter Sent: Wednesday, June 28, 2006 10:01 AM To: San Francisco Perl Mongers User Group Subject: Re: [sf-perl] Quick question on regular expression and substitution On Wed, Jun 28, 2006 at 09:19:15AM -0700, Loo, Peter # PHX wrote: > Hi All, > > Would some one know of a one liner that would replace the third > occurrence of a substring within a string? For example: > > $string = "?, ?, ?, ?"; > > I want to replace the third occurrence of "?" with "to_date(?, > 'YYYY-MM-DD HH24:MI:SS')". > > Thanks in advance. > > Peter Peter, Given the high wackiness of regexes, I'd do something like: $old = '(?, ?, ?, ?)'; # So you're covered on just exactly which clause. $new = q{?, ?, to_date(?, 'YYYY-MM-DD HH24:MI:SS'), ?'}; $query =~ s/$old/$new/; I know it's brute force, but the code is easy to understand later. :) Cheers, D -- David Fetter http://fetter.org/ phone: +1 415 235 3778 AIM: dfetter666 Skype: davidfetter Remember to vote! _______________________________________________ SanFrancisco-pm mailing list SanFrancisco-pm at pm.org http://mail.pm.org/mailman/listinfo/sanfrancisco-pm This E-mail message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply E-mail, and destroy all copies of the original message. From rdm at cfcl.com Wed Jun 28 10:24:00 2006 From: rdm at cfcl.com (Rich Morin) Date: Wed, 28 Jun 2006 10:24:00 -0700 Subject: [sf-perl] Quick question on regular expression and substitution In-Reply-To: <8E3D502A002DA04FADBDED4CB4D94D3A018A12D9@phxmail02.phx.ndchealth.com> References: <8E3D502A002DA04FADBDED4CB4D94D3A018A12D9@phxmail02.phx.ndchealth.com> Message-ID: It might be cleaner to split the string into an array, edit it, and join it back together. -r -- http://www.cfcl.com/rdm Rich Morin http://www.cfcl.com/rdm/resume rdm at cfcl.com http://www.cfcl.com/rdm/weblog +1 650-873-7841 Technical editing and writing, programming, and web development From Peter.Loo at source.wolterskluwer.com Wed Jun 28 10:29:27 2006 From: Peter.Loo at source.wolterskluwer.com (Loo, Peter # PHX) Date: Wed, 28 Jun 2006 10:29:27 -0700 Subject: [sf-perl] Quick question on regular expression and substitution Message-ID: <8E3D502A002DA04FADBDED4CB4D94D3A018A1382@phxmail02.phx.ndchealth.com> I think I am going to have to leave it like this now that I got it working. Here is what I did: sub sub_createInsert($$) { print STDERR "\n***** sub_createInsert() *****\n\n"; my ($tblName, $columnsref) = @_; my ($sqlString, $delimCols, $bindVars, $column, @cols, @temp, $cnt); $cnt = 0; foreach $column (@{$columnsref}) { $cnt++; $timestamp[$cnt] = $cnt if ("@{$column}[1]" =~ m/timestamp/i); $date[$cnt] = $cnt if ("@{$column}[1]" =~ m/date/i); push (@cols, @{$column}[0]); } $delimCols = join(', ', @cols); $bindVars = join ', ', ('?') x @{$columnsref}; @temp = split(/,/, $bindVars); for (my $i=1; $i<=$cnt; $i++) { if ($timestamp[$i]) { $temp[$i] = "to_date(?, 'YYYY-MM-DD HH24:MM:SS')"; } elsif ($date[$i]) { $temp[$i] = "to_date(?)"; } } $bindVars = join(', ', @temp); $sqlString = "insert into " . $tblName . " (" . $delimCols . ") values" . " (" . $bindVars . ")"; print STDERR "RETURNING SQL STRING: $sqlString\n\n"; return($sqlString); } #<=== (End of sub_createInsert) Thanks. Peter -----Original Message----- From: sanfrancisco-pm-bounces+peter.loo=source.wolterskluwer.com at pm.org [mailto:sanfrancisco-pm-bounces+peter.loo=source.wolterskluwer.com at pm.or g] On Behalf Of Rich Morin Sent: Wednesday, June 28, 2006 10:24 AM To: San Francisco Perl Mongers User Group Subject: Re: [sf-perl] Quick question on regular expression and substitution It might be cleaner to split the string into an array, edit it, and join it back together. -r -- http://www.cfcl.com/rdm Rich Morin http://www.cfcl.com/rdm/resume rdm at cfcl.com http://www.cfcl.com/rdm/weblog +1 650-873-7841 Technical editing and writing, programming, and web development _______________________________________________ SanFrancisco-pm mailing list SanFrancisco-pm at pm.org http://mail.pm.org/mailman/listinfo/sanfrancisco-pm This E-mail message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply E-mail, and destroy all copies of the original message. From Adam.Morgan at safeway.com Wed Jun 28 10:31:00 2006 From: Adam.Morgan at safeway.com (Adam Morgan) Date: Wed, 28 Jun 2006 11:31:00 -0600 Subject: [sf-perl] Quick question on regular expression and substitution Message-ID: <5113C869AE8FD844B3589414188D35A97BCF01@PHITPR05EXC01.safeway01.ad.safeway.com> This one works for those situations where you are not sure what will be between the occurences of the character you are trying to replace. It is only any good for single character replaces though as it is below. $string =~ s/^([^?]*\?[^?]*\?[^?]*)(\?)(.*)$/\1to_date(?, 'YYYY-MM-DD HH24:MI:SS')\3/; ________________________________ From: sanfrancisco-pm-bounces+adam.morgan=safeway.com at pm.org [mailto:sanfrancisco-pm-bounces+adam.morgan=safeway.com at pm.org] On Behalf Of Loo, Peter # PHX Sent: Wednesday, June 28, 2006 9:19 AM To: San Francisco Perl Mongers User Group Subject: [sf-perl] Quick question on regular expression and substitution Hi All, Would some one know of a one liner that would replace the third occurrence of a substring within a string? For example: $string = "?, ?, ?, ?"; I want to replace the third occurrence of "?" with "to_date(?, 'YYYY-MM-DD HH24:MI:SS')". Thanks in advance. Peter "MMS " made the following annotations. ------------------------------------------------------------------------------ Warning: All e-mail sent to this address will be received by the Safeway corporate e-mail system, and is subject to archival and review by someone other than the recipient. This e-mail may contain information proprietary to Safeway and is intended only for the use of the intended recipient(s). If the reader of this message is not the intended recipient(s), you are notified that you have received this message in error and that any review, dissemination, distribution or copying of this message is strictly prohibited. If you have received this message in error, please notify the sender immediately. ============================================================================== -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/sanfrancisco-pm/attachments/20060628/334ab4d8/attachment.html From Adam.Morgan at safeway.com Wed Jun 28 10:34:50 2006 From: Adam.Morgan at safeway.com (Adam Morgan) Date: Wed, 28 Jun 2006 11:34:50 -0600 Subject: [sf-perl] Quick question on regular expression and substitution Message-ID: <5113C869AE8FD844B3589414188D35A97BCF02@PHITPR05EXC01.safeway01.ad.safeway.com> The solution I sent has no dependency on what comes after and so may be well suited to your problem. -----Original Message----- From: sanfrancisco-pm-bounces+adam.morgan=safeway.com at pm.org [mailto:sanfrancisco-pm-bounces+adam.morgan=safeway.com at pm.org] On Behalf Of Loo, Peter # PHX Sent: Wednesday, June 28, 2006 10:05 AM To: San Francisco Perl Mongers User Group Subject: Re: [sf-perl] Quick question on regular expression and substitution Hi David, The problem is I won't know what position I need to change. It is all dependent on the query. For example: Another query might return 10 ?s. And within the 10 ?s, I might need to change the 7th "?". Does that make sense? Peter -----Original Message----- From: sanfrancisco-pm-bounces+peter.loo=source.wolterskluwer.com at pm.org [mailto:sanfrancisco-pm-bounces+peter.loo=source.wolterskluwer.com at pm.or g] On Behalf Of David Fetter Sent: Wednesday, June 28, 2006 10:01 AM To: San Francisco Perl Mongers User Group Subject: Re: [sf-perl] Quick question on regular expression and substitution On Wed, Jun 28, 2006 at 09:19:15AM -0700, Loo, Peter # PHX wrote: > Hi All, > > Would some one know of a one liner that would replace the third > occurrence of a substring within a string? For example: > > $string = "?, ?, ?, ?"; > > I want to replace the third occurrence of "?" with "to_date(?, > 'YYYY-MM-DD HH24:MI:SS')". > > Thanks in advance. > > Peter Peter, Given the high wackiness of regexes, I'd do something like: $old = '(?, ?, ?, ?)'; # So you're covered on just exactly which clause. $new = q{?, ?, to_date(?, 'YYYY-MM-DD HH24:MI:SS'), ?'}; $query =~ s/$old/$new/; I know it's brute force, but the code is easy to understand later. :) Cheers, D -- David Fetter http://fetter.org/ phone: +1 415 235 3778 AIM: dfetter666 Skype: davidfetter Remember to vote! _______________________________________________ SanFrancisco-pm mailing list SanFrancisco-pm at pm.org http://mail.pm.org/mailman/listinfo/sanfrancisco-pm This E-mail message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply E-mail, and destroy all copies of the original message. _______________________________________________ SanFrancisco-pm mailing list SanFrancisco-pm at pm.org http://mail.pm.org/mailman/listinfo/sanfrancisco-pm "MMS " made the following annotations. ------------------------------------------------------------------------------ Warning: All e-mail sent to this address will be received by the Safeway corporate e-mail system, and is subject to archival and review by someone other than the recipient. This e-mail may contain information proprietary to Safeway and is intended only for the use of the intended recipient(s). If the reader of this message is not the intended recipient(s), you are notified that you have received this message in error and that any review, dissemination, distribution or copying of this message is strictly prohibited. If you have received this message in error, please notify the sender immediately. ============================================================================== From david at fetter.org Wed Jun 28 10:49:40 2006 From: david at fetter.org (David Fetter) Date: Wed, 28 Jun 2006 10:49:40 -0700 Subject: [sf-perl] Quick question on regular expression and substitution In-Reply-To: <8E3D502A002DA04FADBDED4CB4D94D3A018A1343@phxmail02.phx.ndchealth.com> References: <8E3D502A002DA04FADBDED4CB4D94D3A018A1343@phxmail02.phx.ndchealth.com> Message-ID: <20060628174940.GH1834@fetter.org> On Wed, Jun 28, 2006 at 10:05:11AM -0700, Loo, Peter # PHX wrote: > > Hi David, > > The problem is I won't know what position I need to change. It is > all dependent on the query. I'm sorry to have to put it this way, but it looks like you're trying to machine-generate SQL. After years of watching smart people attempt this, I have come to believe that machine-generated SQL has strong AI as a component, which is Dave-ese for "Don't go there." How about just writing out your SQL in the first place, keeping it somewhere safe, and editing that somewhere at need? Cheers, D -- David Fetter http://fetter.org/ phone: +1 415 235 3778 AIM: dfetter666 Skype: davidfetter Remember to vote! From danlyke at flutterby.com Wed Jun 28 12:13:58 2006 From: danlyke at flutterby.com (Dan Lyke) Date: Wed, 28 Jun 2006 12:13:58 -0700 Subject: [sf-perl] Quick question on regular expression and substitution In-Reply-To: <8E3D502A002DA04FADBDED4CB4D94D3A018A12D9@phxmail02.phx.ndchealth.com> References: <8E3D502A002DA04FADBDED4CB4D94D3A018A12D9@phxmail02.phx.ndchealth.com> Message-ID: On Wed, 28 Jun 2006 09:19:15 -0700, Loo, Peter # PHX wrote: > Would some one know of a one liner that would replace the third > occurrence of a substring within a string? For example: > $string = "?, ?, ?, ?"; my $o = 2; # will replace the third "?" $string =~ s/^((\?, ){$o})\?/$1 to_date(\?, xyz)/; From Peter.Loo at source.wolterskluwer.com Wed Jun 28 15:14:21 2006 From: Peter.Loo at source.wolterskluwer.com (Loo, Peter # PHX) Date: Wed, 28 Jun 2006 15:14:21 -0700 Subject: [sf-perl] Quick question on regular expression and substitution Message-ID: <8E3D502A002DA04FADBDED4CB4D94D3A018A1605@phxmail02.phx.ndchealth.com> Hi David, We have the need to transfer data between several different types of databases. (Oracle, Netezza, SQL Server, Sybase, MySQL, etc...) What I have done is that I created sub-routines to accommodate inserts dynamically. Thanks. Peter -----Original Message----- From: sanfrancisco-pm-bounces+peter.loo=source.wolterskluwer.com at pm.org [mailto:sanfrancisco-pm-bounces+peter.loo=source.wolterskluwer.com at pm.or g] On Behalf Of David Fetter Sent: Wednesday, June 28, 2006 10:50 AM To: San Francisco Perl Mongers User Group Subject: Re: [sf-perl] Quick question on regular expression and substitution On Wed, Jun 28, 2006 at 10:05:11AM -0700, Loo, Peter # PHX wrote: > > Hi David, > > The problem is I won't know what position I need to change. It is all > dependent on the query. I'm sorry to have to put it this way, but it looks like you're trying to machine-generate SQL. After years of watching smart people attempt this, I have come to believe that machine-generated SQL has strong AI as a component, which is Dave-ese for "Don't go there." How about just writing out your SQL in the first place, keeping it somewhere safe, and editing that somewhere at need? Cheers, D -- David Fetter http://fetter.org/ phone: +1 415 235 3778 AIM: dfetter666 Skype: davidfetter Remember to vote! _______________________________________________ SanFrancisco-pm mailing list SanFrancisco-pm at pm.org http://mail.pm.org/mailman/listinfo/sanfrancisco-pm This E-mail message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply E-mail, and destroy all copies of the original message. From david at fetter.org Wed Jun 28 16:27:58 2006 From: david at fetter.org (David Fetter) Date: Wed, 28 Jun 2006 16:27:58 -0700 Subject: [sf-perl] Quick question on regular expression and substitution In-Reply-To: <8E3D502A002DA04FADBDED4CB4D94D3A018A1605@phxmail02.phx.ndchealth.com> References: <8E3D502A002DA04FADBDED4CB4D94D3A018A1605@phxmail02.phx.ndchealth.com> Message-ID: <20060628232758.GB2983@fetter.org> On Wed, Jun 28, 2006 at 03:14:21PM -0700, Loo, Peter # PHX wrote: > > Hi David, > > We have the need to transfer data between several different types of > databases. (Oracle, Netezza, SQL Server, Sybase, MySQL, etc...) > What I have done is that I created sub-routines to accommodate > inserts dynamically. It'll be cheaper, more foolproof, easier to maintain, etc. simply to write the various bits of SQL for each back-end database. You may be interested in the following by Josh Berkus: http://www.powerpostgresql.com/Downloads/database_depends_public.sxi and a sketch of how to accomplish what Josh calls "Multiple Database Support" by yours truly, here: http://fetter.org/Database_As_Object.pdf Cheers, D -- David Fetter http://fetter.org/ phone: +1 415 235 3778 AIM: dfetter666 Skype: davidfetter Remember to vote!