From jobs-noreply at seattleperl.org Tue Jun 2 19:05:23 2009 From: jobs-noreply at seattleperl.org (SPUG Jobs) Date: Tue, 2 Jun 2009 19:05:23 -0700 (PDT) Subject: SPUG: JOB: mod_perl dev, Seattle Message-ID: required skill-set This project will be upgrading all production code to perl 5.8.8, mod_perl2 and Apache 2. Required skills: Perl, apache 2 , mod_perl 2, MySQL, Linux development - contract or permanent position contract - for contracts, expected duration and pay range 90 - negotiable pay - placement through recruiter, or directly with company? W2 through Parker Technical (www.parkertechnical.com) - physical location Seattle - telecommuting possible? Some - company's product or service Social Networking site for car enthusiasts Contact: Jeff Larsen placement consultant parker technical 605 fifth avenue south -suite 850- seattle, wa 98104 jeffl at parkertechnical.com p: 206-652-1516 f: 206-223-8227 Connect with me through LinkedIn From phil.mitchell at pobox.com Wed Jun 10 12:40:32 2009 From: phil.mitchell at pobox.com (Phil Mitchell) Date: Wed, 10 Jun 2009 12:40:32 -0700 Subject: SPUG: ajax character encoding issue solved, but WHY? Message-ID: <3d8716b10906101240u222e1da4xb66f086d8f3f33e7@mail.gmail.com> I solved the character encoding issue that I wrote about earlier, but I don't understand why the fix works. I'm hoping someone can explain this to me! The issue was that non-ascii chars were appearing as junk BUT only when retrieved via ajax calls. Otherwise, they displayed fine. The junk display was due to them being interpreted as ISO-8859-1, but I could not figure out why the browser was interpreting that way. All my data is handled as UTF-8. The problem was fixed by calling Encode::decode on the data prior to sending back via ajax. BUT WHY? I am using the JSON view to render ajax responses, and it sets the charset header correctly to UTF-8. Of course, even when you decode, perl still represents as "internal" utf8. But why should this be necessary? -- ========================== http://www.bikewise.org 2People citizen's network for climate action: http://www.2people.org Greater Seattle Climate Dialogues: http://www.climatedialogues.org ========================== -------------- next part -------------- An HTML attachment was scrubbed... URL: From cjac at colliertech.org Wed Jun 10 12:49:48 2009 From: cjac at colliertech.org (C.J. Adams-Collier) Date: Wed, 10 Jun 2009 12:49:48 -0700 Subject: SPUG: ajax character encoding issue solved, but WHY? In-Reply-To: <3d8716b10906101240u222e1da4xb66f086d8f3f33e7@mail.gmail.com> References: <3d8716b10906101240u222e1da4xb66f086d8f3f33e7@mail.gmail.com> Message-ID: <1244663388.9382.20.camel@norseth> perhaps it didn't know you wanted to decode it as utf-8? http://search.cpan.org/~makamaka/JSON-2.15/lib/JSON.pm#utf8 On Wed, 2009-06-10 at 12:40 -0700, Phil Mitchell wrote: > I solved the character encoding issue that I wrote about earlier, but > I don't understand why the fix works. I'm hoping someone can explain > this to me! > > The issue was that non-ascii chars were appearing as junk BUT only > when retrieved via ajax calls. Otherwise, they displayed fine. The > junk display was due to them being interpreted as ISO-8859-1, but I > could not figure out why the browser was interpreting that way. All my > data is handled as UTF-8. > > The problem was fixed by calling Encode::decode on the data prior to > sending back via ajax. BUT WHY? > > I am using the JSON view to render ajax responses, and it sets the > charset header correctly to UTF-8. Of course, even when you decode, > perl still represents as "internal" utf8. But why should this be > necessary? > > -- > ========================== > http://www.bikewise.org > > 2People citizen's network for climate action: http://www.2people.org > > Greater Seattle Climate Dialogues: http://www.climatedialogues.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 -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: This is a digitally signed message part URL: From andrew at sweger.net Thu Jun 11 13:49:32 2009 From: andrew at sweger.net (Andrew Sweger) Date: Thu, 11 Jun 2009 13:49:32 -0700 (PDT) Subject: SPUG: June 2009 Seattle Perl Users Group (SPUG) Meeting Message-ID: Sorry for the late notice, gang. My bad. I was down in LA hanging out with the drug addicts on Manhattan Beach and just got back last night when I realized we gotta git the SPUG announcement out: June 2009 Seattle Perl Users Group (SPUG) Meeting ==================================================== Topic: Git Best Practices and Gotchas Speaker: Tye McQueen & Dave Olszewski Meeting Date: Tuesday, 16 June 2009 Meeting Time: 6:30 - 8:30 p.m. Location: Marchex - 4th & Pine Cost: Admission is free and open to the public Info: http://seattleperl.org/ ==================================================== Tuesday, June 16, is the next meeting of the THE SEATTLE PERL USERS GROUP. This Month's Talk Git Best Practices and Gotches, and some custom tools to help, especially when using Git as a central repository (as is common in a corporate environment). Q+A may be a popular part of the talk. What is Git? Wikipedia says: Git is a free distributed revision control, or software source code management project with an emphasis on being fast. Git was initially designed and developed by Linus Torvalds for Linux kernel development. Every Git working directory is a full-fledged repository with complete history and full revision tracking capabilities, not dependent on network access or a central server. Several high-profile software projects now use Git for revision control, most notably the Linux kernel, Perl, GNOME, Samba, X.org Server, Qt, One Laptop per Child (OLPC) core development, VLC, Wine, Ruby on Rails, and the Android mobile platform. About Tye McQueen & Dave Olszewski Tye McQueen is a Sr Perl Dev for WhitePages and absentee landlord of PerlMonks.org, proud author of Acme::ESP and several less important modules. Dave Olszewski is a long time perl geek, newfound git geek. Since being thrust into it, he has seen the light and spent many late nights exploring the strange and dusty corners of this life-altering tool. To quote a recent visitor to #git: "who would have f* believed you could get an adrenaline rush from a friggin' SCM!" Pre-Meeting ================ If you are so inclined, please come to the pre-meeting at the Elephant & Castle pub on 5th & Union. We'll be there from 5-6:19PM. Meeting Location ================ Pizza and Beer will be provided at the meeting. Marchex 413 Pine St, Suite 500 Seattle, WA 98101 The building is just south of Westlake Center. Enter on 4th Avenue, near Pine street. The entry is near the Dog In The Park hotdog stand. http://www.baylis.org/static/marchex.png Due to all of the shopping around us there is plenty of parking available in garages, but it can be hard to find street parking in the evening. See you there! From andrew at sweger.net Thu Jun 11 14:00:01 2009 From: andrew at sweger.net (Andrew Sweger) Date: Thu, 11 Jun 2009 14:00:01 -0700 (PDT) Subject: SPUG: June 2009 Seattle Perl Users Group (SPUG) Meeting In-Reply-To: Message-ID: I forgot to mention that this announcement was made possible by a grant from the Colin Meyer Foundation for the Yaml Badger and contributions from listeners like Steve Baylis. And, of course, our thanks to the presenters for offering their time and experience. On Thu, 11 Jun 2009, Andrew Sweger wrote: > Sorry for the late notice, gang. My bad. I was down in LA hanging out with > the drug addicts on Manhattan Beach and just got back last night when I > realized we gotta git the SPUG announcement out: > > June 2009 Seattle Perl Users Group (SPUG) Meeting > ==================================================== > > Topic: Git Best Practices and Gotchas > Speaker: Tye McQueen & Dave Olszewski > Meeting Date: Tuesday, 16 June 2009 > Meeting Time: 6:30 - 8:30 p.m. > Location: Marchex - 4th & Pine > > Cost: Admission is free and open to the public > Info: http://seattleperl.org/ > > ==================================================== > > Tuesday, June 16, is the next meeting of the THE SEATTLE PERL USERS GROUP. > > This Month's Talk > Git Best Practices and Gotches, and some custom tools to help, especially > when using Git as a central repository (as is common in a corporate > environment). Q+A may be a popular part of the talk. > > What is Git? Wikipedia says: Git is a free distributed revision control, > or software source code management project with an emphasis on being fast. > Git was initially designed and developed by Linus Torvalds for Linux > kernel development. Every Git working directory is a full-fledged > repository with complete history and full revision tracking capabilities, > not dependent on network access or a central server. Several high-profile > software projects now use Git for revision control, most notably the > Linux kernel, Perl, GNOME, Samba, X.org Server, Qt, One Laptop per > Child (OLPC) core development, VLC, Wine, Ruby on Rails, and the > Android mobile platform. > > About Tye McQueen & Dave Olszewski > Tye McQueen is a Sr Perl Dev for WhitePages and absentee landlord of > PerlMonks.org, proud author of Acme::ESP and several less important > modules. > > Dave Olszewski is a long time perl geek, newfound git geek. Since being > thrust into it, he has seen the light and spent many late nights exploring > the strange and dusty corners of this life-altering tool. To quote a > recent visitor to #git: "who would have f* believed you could get an > adrenaline rush from a friggin' SCM!" > > > Pre-Meeting > ================ > > If you are so inclined, please come to the pre-meeting at the Elephant & > Castle pub on 5th & Union. We'll be there from 5-6:19PM. > > Meeting Location > ================ > > Pizza and Beer will be provided at the meeting. > > Marchex > 413 Pine St, Suite 500 > Seattle, WA 98101 > > > The building is just south of Westlake Center. Enter on 4th Avenue, near > Pine street. The entry is near the Dog In The Park hotdog stand. > > http://www.baylis.org/static/marchex.png > > Due to all of the shopping around us there is plenty of parking > available in garages, but it can be hard to find street parking in > the evening. > > See you there! > > > _____________________________________________________________ > 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/ > -- Andrew B. Sweger -- The great thing about multitasking is that several things can go wrong at once. From andrew at sweger.net Mon Jun 15 10:50:28 2009 From: andrew at sweger.net (Andrew Sweger) Date: Mon, 15 Jun 2009 10:50:28 -0700 (PDT) Subject: SPUG: Meeting Reminder: June 2009 Seattle Perl Users Group (SPUG) Meeting In-Reply-To: Message-ID: Just a reminder that your SPUG meeting is tomorrow evening. Details below. On Thu, 11 Jun 2009, Andrew Sweger wrote: > Sorry for the late notice, gang. My bad. I was down in LA hanging out with > the drug addicts on Manhattan Beach and just got back last night when I > realized we gotta git the SPUG announcement out: > > June 2009 Seattle Perl Users Group (SPUG) Meeting > ==================================================== > > Topic: Git Best Practices and Gotchas > Speaker: Tye McQueen & Dave Olszewski > Meeting Date: Tuesday, 16 June 2009 > Meeting Time: 6:30 - 8:30 p.m. > Location: Marchex - 4th & Pine > > Cost: Admission is free and open to the public > Info: http://seattleperl.org/ > > ==================================================== > > Tuesday, June 16, is the next meeting of the THE SEATTLE PERL USERS GROUP. > > This Month's Talk > Git Best Practices and Gotches, and some custom tools to help, especially > when using Git as a central repository (as is common in a corporate > environment). Q+A may be a popular part of the talk. > > What is Git? Wikipedia says: Git is a free distributed revision control, > or software source code management project with an emphasis on being fast. > Git was initially designed and developed by Linus Torvalds for Linux > kernel development. Every Git working directory is a full-fledged > repository with complete history and full revision tracking capabilities, > not dependent on network access or a central server. Several high-profile > software projects now use Git for revision control, most notably the > Linux kernel, Perl, GNOME, Samba, X.org Server, Qt, One Laptop per > Child (OLPC) core development, VLC, Wine, Ruby on Rails, and the > Android mobile platform. > > About Tye McQueen & Dave Olszewski > Tye McQueen is a Sr Perl Dev for WhitePages and absentee landlord of > PerlMonks.org, proud author of Acme::ESP and several less important > modules. > > Dave Olszewski is a long time perl geek, newfound git geek. Since being > thrust into it, he has seen the light and spent many late nights exploring > the strange and dusty corners of this life-altering tool. To quote a > recent visitor to #git: "who would have f* believed you could get an > adrenaline rush from a friggin' SCM!" > > > Pre-Meeting > ================ > > If you are so inclined, please come to the pre-meeting at the Elephant & > Castle pub on 5th & Union. We'll be there from 5-6:19PM. > > Meeting Location > ================ > > Pizza and Beer will be provided at the meeting. > > Marchex > 413 Pine St, Suite 500 > Seattle, WA 98101 > > > The building is just south of Westlake Center. Enter on 4th Avenue, near > Pine street. The entry is near the Dog In The Park hotdog stand. > > http://www.baylis.org/static/marchex.png > > Due to all of the shopping around us there is plenty of parking > available in garages, but it can be hard to find street parking in > the evening. > > See you there! > > > _____________________________________________________________ > 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/ > -- Andrew B. Sweger -- The great thing about multitasking is that several things can go wrong at once. From mark.johnston at pnl.gov Tue Jun 16 09:55:15 2009 From: mark.johnston at pnl.gov (Johnston, Mark) Date: Tue, 16 Jun 2009 09:55:15 -0700 Subject: SPUG: ajax character encoding issue solved, but WHY? In-Reply-To: <3d8716b10906101240u222e1da4xb66f086d8f3f33e7@mail.gmail.com> References: <3d8716b10906101240u222e1da4xb66f086d8f3f33e7@mail.gmail.com> Message-ID: <40F884121DC910468990254D345A4F3306012617@EMAIL01.pnl.gov> Phil, This is a shot in the dark, but is the encoding on the page that interacts with the web service via AJAX by chance ISO-8859-1 (either set explicitly or by default on the server)? You didn't mention whether "utf8" or "UTF-8" is the character encoding you are now specifying when calling Encode::decode on the JSON text stream, so I'm not sure how that might have affected the resulting text stream as it enters the wire between the two processes. The world of character encoding is fraught with all kinds of interesting situations. Once upon a time a "byte" and "character" were interchangeable, and all was well with the world ... 8^)) ... In the world of processes operating under different character encoding schemes, however, sometimes the waters get muddled. If the sender and receiver are not in absolute agreement as to the character encoding of a stream of bytes (_and_ capable of translating between character encodings when necessary), the interpretation of what characters are meant by a particular byte stream can be different, which leads to the type of problem you describe. --Mark ________________________________ From: spug-list-bounces+mark.johnston=pnl.gov at pm.org [mailto:spug-list-bounces+mark.johnston=pnl.gov at pm.org] On Behalf Of Phil Mitchell Sent: Wednesday, June 10, 2009 12:41 PM To: spug-list at mail.pm.org Subject: SPUG: ajax character encoding issue solved, but WHY? I solved the character encoding issue that I wrote about earlier, but I don't understand why the fix works. I'm hoping someone can explain this to me! The issue was that non-ascii chars were appearing as junk BUT only when retrieved via ajax calls. Otherwise, they displayed fine. The junk display was due to them being interpreted as ISO-8859-1, but I could not figure out why the browser was interpreting that way. All my data is handled as UTF-8. The problem was fixed by calling Encode::decode on the data prior to sending back via ajax. BUT WHY? I am using the JSON view to render ajax responses, and it sets the charset header correctly to UTF-8. Of course, even when you decode, perl still represents as "internal" utf8. But why should this be necessary? -- ========================== http://www.bikewise.org 2People citizen's network for climate action: http://www.2people.org Greater Seattle Climate Dialogues: http://www.climatedialogues.org ========================== -------------- next part -------------- An HTML attachment was scrubbed... URL: From phil.mitchell at pobox.com Tue Jun 16 20:47:04 2009 From: phil.mitchell at pobox.com (Phil Mitchell) Date: Tue, 16 Jun 2009 20:47:04 -0700 Subject: SPUG: ajax character encoding issue solved, but WHY? In-Reply-To: <40F884121DC910468990254D345A4F3306012617@EMAIL01.pnl.gov> References: <3d8716b10906101240u222e1da4xb66f086d8f3f33e7@mail.gmail.com> <40F884121DC910468990254D345A4F3306012617@EMAIL01.pnl.gov> Message-ID: <3d8716b10906162047y71e10991x981d9dd480ca3d4@mail.gmail.com> On Tue, Jun 16, 2009 at 9:55 AM, Johnston, Mark wrote: > Phil, > > This is a shot in the dark, but is the encoding on the page that > interacts with the web service via AJAX by chance ISO-8859-1 (either set > explicitly or by default on the server)? > No, all my html is served with charset=UTF-8 > You didn't mention whether "utf8" or "UTF-8" is the character encoding you > are now specifying when calling Encode::decode on the JSON text stream, so > I'm not sure how that might have affected the resulting text stream as it > enters the wire between the two processes. > It doesn't seem to matter, both work. In fact, I ended up using utf8::decode, thinking perhaps it is the most efficient. I remain puzzled, but thanks for thinking about it! Phil > > > > > ------------------------------ > *From:* spug-list-bounces+mark.johnston=pnl.gov at pm.org [mailto: > spug-list-bounces+mark.johnston = > pnl.gov at pm.org] *On Behalf Of *Phil Mitchell > *Sent:* Wednesday, June 10, 2009 12:41 PM > *To:* spug-list at mail.pm.org > *Subject:* SPUG: ajax character encoding issue solved, but WHY? > > I solved the character encoding issue that I wrote about earlier, but I > don't understand why the fix works. I'm hoping someone can explain this to > me! > > The issue was that non-ascii chars were appearing as junk BUT only when > retrieved via ajax calls. Otherwise, they displayed fine. The junk display > was due to them being interpreted as ISO-8859-1, but I could not figure out > why the browser was interpreting that way. All my data is handled as UTF-8. > > The problem was fixed by calling Encode::decode on the data prior to > sending back via ajax. BUT WHY? > > I am using the JSON view to render ajax responses, and it sets the charset > header correctly to UTF-8. Of course, even when you decode, perl still > represents as "internal" utf8. But why should this be necessary? > > -- > ========================== > http://www.bikewise.org > > 2People citizen's network for climate action: http://www.2people.org > > Greater Seattle Climate Dialogues: http://www.climatedialogues.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/ > -- ========================== http://www.bikewise.org 2People citizen's network for climate action: http://www.2people.org Greater Seattle Climate Dialogues: http://www.climatedialogues.org ========================== -------------- next part -------------- An HTML attachment was scrubbed... URL: From ingy at ingy.net Wed Jun 17 15:14:07 2009 From: ingy at ingy.net (Ingy dot Net) Date: Wed, 17 Jun 2009 15:14:07 -0700 Subject: SPUG: The TestML Mailing List Message-ID: <9eb4914f0906171514v664619c1kf397e419b2b1f235@mail.gmail.com> Greetings, Ingy here... You are getting this email because I want you involved in the TestML discussion mailing list. Some of you already are on the list, so sorry for any redundancy. TestML is a generic software testing framework that transcends programming languages and their test frameworks. It is something that I've been thinking about for 3-4 years and hacking on for a couple months. The spec is at http://testml.org and the code is under http://github.com/ingydotnet/(testml-*). I have been frustrated with the mailing list options available to me. I started with Google Groups and have decided to stick with it for now. Google Apps handles all the email, even though I so far find Groups to be somewhat hateful. The "mailing list" address is discuss at testml.org. I don't have any _good_ way for you to subscribe or unsubscribe, but I do have _a_ way. Send an email from the address you want to use for this, and I will personally subscribe/unsubscribe you. Send the email either to ingy at ingy.net or to discuss at testml.org (it actually allows mail from non-subscribers). Hopefully I'll get this ironed out, but at least now I can continue the TestML discussion and make progress. If you have experience with Groups combined with Apps under a custom domain name (like testml.org) please help me out. I really look forward to discussing TestML with all of you. Cheers, Ingy -------------- next part -------------- An HTML attachment was scrubbed... URL: From jobs-noreply at seattleperl.org Tue Jun 23 16:59:10 2009 From: jobs-noreply at seattleperl.org (SPUG Jobs) Date: Tue, 23 Jun 2009 16:59:10 -0700 (PDT) Subject: SPUG: JOB: Perl App Developer - contract Message-ID: Required: Perl _application_ development experience. Script jockey not adequate. W2 Contract position: 2 weeks - 3 months. 20-40 hours per week onsite. Pay rate near $30/hr. Local candidates only. Developing automated test tools for outsourcing firm. Jeff Larsen placement consultant parker technical 605 fifth avenue south -suite 850- seattle, wa 98104 jeffl at parkertechnical.com | p: 206-652-1516 | f: 206-223-8227 Connect with me through LinkedIn http://www.linkedin.com/in/jeffdlarsen From ryanc at greengrey.org Wed Jun 24 15:49:24 2009 From: ryanc at greengrey.org (Ryan Corder) Date: Wed, 24 Jun 2009 15:49:24 -0700 Subject: SPUG: multi-line substition, all at once. Message-ID: <20090624224924.GA2801@greengrey.org> Greetings all, I'm trying to do a multi-line substitution of a particular sort and things aren't quite working out. I've been grinding at it for a little bit now to the point that I think it's time to ask for some assitance. I'm using 5.10. Say I have the following: my $code=<<__CODE__; : sub hello { : say "Hello World!"; : } __CODE__ I would like to get back: [code] sub hello { say "Hello World!"; } [/code] I've been playing around with the zero-width lookbehind assertions, but it seems as if the positive (?<=) and negative (? || /\ against HTML email http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x1CB59D69 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 195 bytes Desc: not available URL: From jwkrahn at shaw.ca Wed Jun 24 17:25:08 2009 From: jwkrahn at shaw.ca (John W. Krahn) Date: Wed, 24 Jun 2009 17:25:08 -0700 Subject: SPUG: multi-line substition, all at once. In-Reply-To: <20090624224924.GA2801@greengrey.org> References: <20090624224924.GA2801@greengrey.org> Message-ID: <4A42C3E4.2010603@shaw.ca> Ryan Corder wrote: > Greetings all, Hello, > I'm trying to do a multi-line substitution of a particular sort and things > aren't quite working out. I've been grinding at it for a little bit now > to the point that I think it's time to ask for some assitance. I'm using 5.10. > > Say I have the following: > > my $code=<<__CODE__; > : sub hello { > : say "Hello World!"; > : } > __CODE__ > > I would like to get back: > > [code] sub hello { > say "Hello World!"; > } > [/code] > > I've been playing around with the zero-width lookbehind assertions, but it > seems as if the positive (?<=) and negative (? are supposed to make the match, but not include it in $&. Negative works > that way, but positive is including or so it seems. Here is what I have so > far... > > $code =~ s@(?:(?<=\s\:).*)+@"[code]$&[/code]"@esg; (gives me) > > :[code] sub hello { > : say "Hello World!"; > : } > [/code] > > $code =~ s@(^(\s\:)(.*)$)+@"[code]$3[/code]"@esg; (gives me) > > [code] sub hello { > : say "Hello World!"; > : } > [/code] > > Both are close in their own ways, but no cigar. I've tried other permutations > of the regex to no avail. > > I know I could do this with two regex, but for reasons that are not pertinent > to the discusion, I would really like to do this with one. > > Any hints? $ perl -le' my $code = <<__CODE__; : sub hello { : say "Hello World!"; : } __CODE__ ( $code = "[code]$code\[/code]" ) =~ s/ +://g; print $code; ' [code] sub hello { say "Hello World!"; } [/code] John -- Those people who think they know everything are a great annoyance to those of us who do. -- Isaac Asimov From ryanc at greengrey.org Wed Jun 24 17:35:09 2009 From: ryanc at greengrey.org (Ryan Corder) Date: Wed, 24 Jun 2009 17:35:09 -0700 Subject: SPUG: multi-line substition, all at once. In-Reply-To: <4A42C3E4.2010603@shaw.ca> References: <20090624224924.GA2801@greengrey.org> <4A42C3E4.2010603@shaw.ca> Message-ID: <20090625003509.GA6042@greengrey.org> On Wed, Jun 24, 2009 at 05:25:08PM -0700, John W. Krahn wrote: > $ perl -le' > my $code = <<__CODE__; > : sub hello { > : say "Hello World!"; > : } > __CODE__ > > ( $code = "[code]$code\[/code]" ) =~ s/ +://g; > > print $code; > ' > [code] sub hello { > say "Hello World!"; > } > [/code] After I sent my initial email, I had a feeling that your answer would be the first one back and that is entirely my fault. I should have specified that $code would most likely contain lines of text before and after the lines that begin with ':'. So, I can't just wrap $code with [code] tags and then do a simple substitute on it. Sorry about the lack of clarity in my example. -- Ryan Corder || () ASCII ribbon campaign || /\ against HTML email http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x1CB59D69 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 195 bytes Desc: not available URL: From derykus at gmail.com Wed Jun 24 19:48:22 2009 From: derykus at gmail.com (Charles DeRykus) Date: Wed, 24 Jun 2009 19:48:22 -0700 Subject: SPUG: multi-line substition, all at once. In-Reply-To: <20090625003509.GA6042@greengrey.org> References: <20090624224924.GA2801@greengrey.org> <4A42C3E4.2010603@shaw.ca> <20090625003509.GA6042@greengrey.org> Message-ID: <175825720906241948q70f14764p36a404f756c9fd0e@mail.gmail.com> On Wed, Jun 24, 2009 at 5:35 PM, Ryan Corder wrote: > On Wed, Jun 24, 2009 at 05:25:08PM -0700, John W. Krahn wrote: > > $ perl -le' > > my $code = <<__CODE__; > > : sub hello { > > : say "Hello World!"; > > : } > > __CODE__ > > > > ( $code = "[code]$code\[/code]" ) =~ s/ +://g; > > > > print $code; > > ' > > [code] sub hello { > > say "Hello World!"; > > } > > [/code] > > >>After I sent my initial email, I had a feeling that your >>answer would > be the first one back and that is >> entirely my fault. I should have specified that >> $code would most likely contain lines > >> of text before and after the lines that begin with ':'. >>So, I can't > just wrap $code with [code] tags and then >> do a simple substitute on it. > Er, wouldn't this work even with the added qualification: $code = "[code]${code}[\\code]"; $code =~ s/^ ://gm; -- Charles DeRykus -------------- next part -------------- An HTML attachment was scrubbed... URL: From ryanc at greengrey.org Thu Jun 25 00:00:43 2009 From: ryanc at greengrey.org (Ryan Corder) Date: Thu, 25 Jun 2009 00:00:43 -0700 Subject: SPUG: multi-line substition, all at once. In-Reply-To: <175825720906241948q70f14764p36a404f756c9fd0e@mail.gmail.com> References: <20090624224924.GA2801@greengrey.org> <4A42C3E4.2010603@shaw.ca> <20090625003509.GA6042@greengrey.org> <175825720906241948q70f14764p36a404f756c9fd0e@mail.gmail.com> Message-ID: <20090625070043.GB4127@greengrey.org> On Wed, Jun 24, 2009 at 07:48:22PM -0700, Charles DeRykus wrote: | Er, wouldn't this work even with the added qualification: | | $code = "[code]${code}[\\code]"; | $code =~ s/^ ://gm; No, that's the same problem. I can't just wrap the entirety of $code inside [code] tags. Using your example and if $code contained the following: my $code=<<__CODE__; foo bar baz : sub hello { : say "Hello World!"; : } asdf snap crackle pop __CODE__ The output would like like this: [code]foo bar baz sub hello { say "Hello World!"; } asdf snap crackle pop [/code] which doesn't work for me. I need to insert the [code] tags on either side of the substitution, inline with any content that may already be there. -- Ryan Corder || () ASCII ribbon campaign || /\ against HTML email http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x1CB59D69 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 195 bytes Desc: not available URL: From jarich at perltraining.com.au Thu Jun 25 04:25:30 2009 From: jarich at perltraining.com.au (Jacinta Richardson) Date: Thu, 25 Jun 2009 21:25:30 +1000 Subject: SPUG: multi-line substition, all at once. In-Reply-To: <20090624224924.GA2801@greengrey.org> References: <20090624224924.GA2801@greengrey.org> Message-ID: <4A435EAA.3000503@perltraining.com.au> Ryan Corder wrote: > my $code=<<__CODE__; > : sub hello { > : say "Hello World!"; > : } > __CODE__ > > I would like to get back: > > [code] sub hello { > say "Hello World!"; > } > [/code] and > my $code=<<__CODE__; > foo bar > baz > > : sub hello { > : say "Hello World!"; > : } > asdf > snap > crackle > pop > __CODE__ > > [code] > sub hello { > say "Hello World!"; > } > [/code] right? It's a good idea to be explicit about your HEREDOC quoting. By default it's double quotes, but it doesn't hurt to put them in. I also don't recommend using @ as your delimiters in substitutions, but that's because they hurt my eyes (and my syntax highlighting doesn't understand them). You had this: $code =~ s@(?:(?<=\s\:).*)+@"[code]$&[/code]"@esg; which could be more nicely written as: $code =~ s{ (?: # Non-capturing match (?<=\s:) # follows a space and a : .* )+ # one or more } {[code]$&\[/code]}sgx; or, to get rid of the assertion: $code =~ s{ ( ^\s: # the line starts with space: .* )+ # one or more } {[code]$&\[/code]}msgx; Note that I do need to escape the second [ on the right handside (as your code should have too), but I don't need quotes or /e (neither did you). The right hand side of a substitute already acts as a double quoted string. As you point out all of these patterns return: :[code] sub hello { : say "Hello World!"; : } [/code] Which isn't quite right. Worse they behave completely wrong when given more complex data: foo bar baz [code] : sub hello { : say "Hello World!"; : } asdf snap crackle pop The expression below works better: my $code = ' foo bar baz : sub hello { : say "Hello World!"; : } asdf snap crackle pop '; $code =~ s{ \A.*? # Get rid of any excess at the top ( # start $1 ( ^ # start of a line \s: # space then colon [^\n]*\n # just 1 line (including newline) )+ # one or more times ) # end of $1 .* }{[code]$1\[/code]\n}sxm; print $code; __END__ [code] : sub hello { : say "Hello World!"; : } [/code] The problem is that you want to both capture the lines which are identified by starting with the space: and then you want to remove the space:. I don't believe that this can be done (at least in an efficient and readable fashion) without cheating. Here's an example of cheating: my $code = ' foo bar baz : sub hello { : say "Hello World!"; : } asdf snap crackle pop '; $code =~ s{ \A.*? # Get rid of any excess at the top ( # start $1 ( ^ # start of a line \s: # space then colon [^\n]*\n # just 1 line (including newline) )+ # one or more times ) # end of $1 .* }{"[code]\n".no_colon($1)."[/code]\n"}sexm; print $code; sub no_colon { my $line = shift; $line =~ s/^ ://gm; return $line; } __END__ [code] sub hello { say "Hello World!"; } [/code] This still uses two regular expressions, we just hide one of them away in a subroutine. I don't really like using /e, so I'd still suggest doing this in two expressions, such as the example previous plus $code =~ s/^ ://gm; You *might* be able to achieve this in one regular expression using a re-entrant expression, but I haven't been able to, and I don't think it would be easily maintainable. All the best, J -- ("`-''-/").___..--''"`-._ | Jacinta Richardson | `6_ 6 ) `-. ( ).`-.__.`) | Perl Training Australia | (_Y_.)' ._ ) `._ `. ``-..-' | +61 3 9354 6001 | _..`--'_..-_/ /--'_.' ,' | contact at perltraining.com.au | (il),-'' (li),' ((!.-' | www.perltraining.com.au | From derykus at gmail.com Thu Jun 25 06:33:54 2009 From: derykus at gmail.com (Charles DeRykus) Date: Thu, 25 Jun 2009 06:33:54 -0700 Subject: SPUG: multi-line substition, all at once. In-Reply-To: <20090625070043.GB4127@greengrey.org> References: <20090624224924.GA2801@greengrey.org> <4A42C3E4.2010603@shaw.ca> <20090625003509.GA6042@greengrey.org> <175825720906241948q70f14764p36a404f756c9fd0e@mail.gmail.com> <20090625070043.GB4127@greengrey.org> Message-ID: <175825720906250633s17f937f4tf2f1c59a7f0325d4@mail.gmail.com> Here's a horrible possibility using a code assertion: my $end = 0; my $st = 0 # no comments to discourage usage $code =~ s/ ^(?: \s:(?{$st++;}) | (?{ $end++ if $st }) ) / $st == 1 ? "" : ($end==1 ? "<\\code>" : "") /gmex; which produces: foo bar baz sub hello { say "Hello World!"; } <\code>asdf snap crackle pop --- Charles DeRykus On Thu, Jun 25, 2009 at 12:00 AM, Ryan Corder wrote: > On Wed, Jun 24, 2009 at 07:48:22PM -0700, Charles DeRykus wrote: > | Er, wouldn't this work even with the added qualification: > | > | $code = "[code]${code}[\\code]"; > | $code =~ s/^ ://gm; > > No, that's the same problem. I can't just wrap the entirety of $code > inside [code] tags. Using your example and if $code contained the > following: > > my $code=<<__CODE__; > foo bar > baz > > : sub hello { > : say "Hello World!"; > : } > asdf > snap > crackle > pop > __CODE__ > > The output would like like this: > > [code]foo bar > baz > > sub hello { > say "Hello World!"; > } > asdf > snap crackle > pop > [/code] > > which doesn't work for me. I need to insert the [code] tags on either > side of the substitution, inline with any content that may already be > there. > > > -- > Ryan Corder || () ASCII ribbon campaign > || /\ against HTML email > http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x1CB59D69 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jarich at perltraining.com.au Mon Jun 29 03:29:50 2009 From: jarich at perltraining.com.au (Jacinta Richardson) Date: Mon, 29 Jun 2009 20:29:50 +1000 Subject: SPUG: multi-line substition, all at once. In-Reply-To: <20090624224924.GA2801@greengrey.org> References: <20090624224924.GA2801@greengrey.org> Message-ID: <4A48979E.6040708@perltraining.com.au> So Ryan, How did you end up solving it? J -- ("`-''-/").___..--''"`-._ | Jacinta Richardson | `6_ 6 ) `-. ( ).`-.__.`) | Perl Training Australia | (_Y_.)' ._ ) `._ `. ``-..-' | +61 3 9354 6001 | _..`--'_..-_/ /--'_.' ,' | contact at perltraining.com.au | (il),-'' (li),' ((!.-' | www.perltraining.com.au | From twists at gmail.com Mon Jun 29 08:29:18 2009 From: twists at gmail.com (Joshua ben Jore) Date: Mon, 29 Jun 2009 08:29:18 -0700 Subject: SPUG: multi-line substition, all at once. In-Reply-To: <4A435EAA.3000503@perltraining.com.au> References: <20090624224924.GA2801@greengrey.org> <4A435EAA.3000503@perltraining.com.au> Message-ID: =email On Thu, Jun 25, 2009 at 4:25 AM, Jacinta Richardson wrote: I found I liked your approach quite a bit so I've written this email as a program for you. Starting off, I'm using your suggestion to be explicit about my heredoc quoting. What follows is an example of using single-quoting so I know there's no interpolation. =cut use strict; use warnings; use Test::More tests => 1; my $code=<<'__CODE__'; ... : sub hello { : say "Hello World!"; : } ... __CODE__ =email The core regexp is rather simple. I found it nicer to put it into its own variable so I could go back later and test that it was working correctly with Test::Regexp. The base regexp just finds a series of lines starting with some spaces and a colon. The modification work is delegated to an s{$RX}{ code }e expression. Now that the pattern is separate, I can pay more attention to each in its own idiom. =cut my $RX = qr/(?mx) # allow whitespace and comments, ^ matches some line beginning # Capture... ( (?: # A series... ^\ +:[^\n]*\n # of colon marked lines )+ ) /; =email I'll also use Jacinta's no_colon to remove the leading colon markers. =cut sub no_colon { my ( $code ) = @_; $code =~ s/^ +://mg; return $code; } =email I added one more function for adding the [code] tags. The point being, while I was doing all this mucking around, I might as well make the eventual expression as readable as possible. =cut sub code_tag { my ( $code ) = @_; "[code]$code\[/$code]"; } =email All the work happens in a very small space now and I hope is more readable. In particular, I learned to use {} bracing for expressions I'm going to use with /e because then it looks more like normal code bracing. It's a small hint to the reader to expect code. =cut $code =~ s{$RX}{ code_tag( no_colon( $1 )); }e; =email Lastly, since I was going to this effort, I wrote a test to check that I was doing what I expected. =cut is( $code, <<'__EXPECTED__' ); ... [code] sub hello { say "Hello World!"; } [/code] ... __EXPECTED__ =email Cheers, Josh =cut From jarich at perltraining.com.au Mon Jun 29 17:53:59 2009 From: jarich at perltraining.com.au (Jacinta Richardson) Date: Tue, 30 Jun 2009 10:53:59 +1000 Subject: SPUG: multi-line substition, all at once. In-Reply-To: References: <20090624224924.GA2801@greengrey.org> <4A435EAA.3000503@perltraining.com.au> Message-ID: <4A496227.6090209@perltraining.com.au> Joshua ben Jore wrote: > sub code_tag { > my ( $code ) = @_; > "[code]$code\[/$code]"; > } I presume the third "$code" there is a typo and should have been just "code". Otherwise, looks good. J -- ("`-''-/").___..--''"`-._ | Jacinta Richardson | `6_ 6 ) `-. ( ).`-.__.`) | Perl Training Australia | (_Y_.)' ._ ) `._ `. ``-..-' | +61 3 9354 6001 | _..`--'_..-_/ /--'_.' ,' | contact at perltraining.com.au | (il),-'' (li),' ((!.-' | www.perltraining.com.au |