From mike at stok.ca Thu Mar 3 03:54:38 2011 From: mike at stok.ca (Mike Stok) Date: Thu, 3 Mar 2011 06:54:38 -0500 Subject: [tpm] Fwd: UG News--Ebook Deal/Day: Save 50% on O'Reilly Editor Brian Sawyer's Geek Culture Picks References: <1299139719.26074.0.711066@post.oreilly.com> Message-ID: <0C68EE5D-4B9A-4E63-B1FD-47BC20DC07C7@stok.ca> View in browser. Forward this announcement to your user group or a friend Save 50% Ebook Deal of the Day O'Reilly Editor Brian Sawyer's Geek Culture Picks Whether you consider yourself a geek or not, I'm sure you'll find each of these books interesting. You might even find yourself "geeking out" over something completely new, which is a wonderful new feeling to discover. For one day only you can buy these titles for 50% off. Use discount code DDG3K. Ebooks from oreilly.com are DRM-free. You get free lifetime access, multiple file formats, free updates. Being Geek Was: $19.99 Now: $9.99 Cooking for Geeks Was: $27.99 Now: $13.99 Geek Atlas Was: $23.99 Now: $11.99 Related titles also included in this deal: Hacking: The Next Generation Was: $31.99 Now: $15.99 Mind Hacks Was: $19.99 Now: $9.99 Mind Performance Hacks Was: $19.99 Now: $9.99 Hackers & Painters Was: $18.99 Now: $9.49 Revolution in The Valley Was: $19.99 Now: $9.99 The Google Way Was: $19.95 Now: $9.97 Hacking: The Art of Exploitation Was: $39.95 Now: $19.97 Eloquent JavaScript Was: $23.95 Now: $11.97 The Book of Audacity Was: $27.95 Now: $13.97 Land of Lisp Was: $39.95 Now: $19.97 You are receiving this email because you are a User Group contact with O'Reilly Media. Forward this announcement. If you would like to stop receiving these newsletters or announcements from O'Reilly, send an email to marsee at oreilly.com. O'Reilly Media, Inc. 1005 Gravenstein Highway North, Sebastopol, CA 95472 (707) 827-7000 -- Mike Stok http://www.stok.ca/~mike/ The "`Stok' disclaimers" apply. -------------- next part -------------- An HTML attachment was scrubbed... URL: From uri at StemSystems.com Sat Mar 5 22:35:45 2011 From: uri at StemSystems.com (Uri Guttman) Date: Sun, 06 Mar 2011 01:35:45 -0500 Subject: [tpm] how did you arrange a damian visit? Message-ID: <87mxl8ycvy.fsf@quad.sysarch.com> hi all, i know in the past you brought damian conway to toronto by collecting funds to cover a side trip there during his NA tour. i would like to organize a similar thing for boston so i would like some info on how you did it. what was the budget for the visit? how did you collect the money? what was the mix from companies vs individuals? any other info you can send me would be great. we have had damian talk in boston before but that was always when he was already in town doing training. this would be our first time trying to get him to make a side trip. thanx, uri -- Uri Guttman ------ uri at stemsystems.com -------- http://www.sysarch.com -- ----- Perl Code Review , Architecture, Development, Training, Support ------ --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com --------- From legrady at gmail.com Sun Mar 6 07:10:42 2011 From: legrady at gmail.com (Tom Legrady) Date: Sun, 6 Mar 2011 10:10:42 -0500 Subject: [tpm] how did you arrange a damian visit? In-Reply-To: <87mxl8ycvy.fsf@quad.sysarch.com> References: <87mxl8ycvy.fsf@quad.sysarch.com> Message-ID: If he comes as close as Boston, can we get him to Toronto? I's been years On Sun, Mar 6, 2011 at 1:35 AM, Uri Guttman wrote: > > hi all, > > i know in the past you brought damian conway to toronto by collecting > funds to cover a side trip there during his NA tour. i would like to > organize a similar thing for boston so i would like some info on how you > did it. what was the budget for the visit? how did you collect the > money? what was the mix from companies vs individuals? any other info > you can send me would be great. we have had damian talk in boston before > but that was always when he was already in town doing training. this > would be our first time trying to get him to make a side trip. > > thanx, > > uri > > -- > Uri Guttman ------ uri at stemsystems.com -------- http://www.sysarch.com-- > ----- Perl Code Review , Architecture, Development, Training, Support > ------ > --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com--------- > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm > -------------- next part -------------- An HTML attachment was scrubbed... URL: From alexmac131 at hotmail.com Sun Mar 6 09:53:50 2011 From: alexmac131 at hotmail.com (alexmac131 at hotmail.com) Date: Sun, 6 Mar 2011 12:53:50 -0500 Subject: [tpm] how did you arrange a damian visit? In-Reply-To: References: <87mxl8ycvy.fsf@quad.sysarch.com> Message-ID: put me down for donation call if you want to bring him here. will toss in 300 Sent from the Viking 2 Lander On 2011-03-06, at 10:10 AM, Tom Legrady wrote: > If he comes as close as Boston, can we get him to Toronto? I's been years > > On Sun, Mar 6, 2011 at 1:35 AM, Uri Guttman wrote: > > hi all, > > i know in the past you brought damian conway to toronto by collecting > funds to cover a side trip there during his NA tour. i would like to > organize a similar thing for boston so i would like some info on how you > did it. what was the budget for the visit? how did you collect the > money? what was the mix from companies vs individuals? any other info > you can send me would be great. we have had damian talk in boston before > but that was always when he was already in town doing training. this > would be our first time trying to get him to make a side trip. > > thanx, > > uri > > -- > Uri Guttman ------ uri at stemsystems.com -------- http://www.sysarch.com -- > ----- Perl Code Review , Architecture, Development, Training, Support ------ > --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com --------- > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm > > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm -------------- next part -------------- An HTML attachment was scrubbed... URL: From rdice at pobox.com Sun Mar 6 11:26:51 2011 From: rdice at pobox.com (Richard Dice) Date: Sun, 6 Mar 2011 14:26:51 -0500 Subject: [tpm] how did you arrange a damian visit? In-Reply-To: References: <87mxl8ycvy.fsf@quad.sysarch.com> Message-ID: Hi Uri, I have been the main organizer for Damian in those years when he has come to Toronto. I'll give you my impressions of what I did that made those trips work out. It was easier back in the years when he would come to N. America for YAPC::NA, because then he'd hang around *somewhere* on the continent to wait until OSCON. His time was relatively cheap, so gathering together enough in personal donations to pay for his trip (within N.America), hotel for a few days, and incidentals (meals, etc.) wasn't too hard. Maybe $1500 would do it for a 3-4 day long trip. I found that the Toronto Perl Mongers were incredibly generous to donate much, and donate it quickly. I would collect the money usually as cash, either at TPM meetings in the months leading up to Damian's visit or actually at his talk sessions. Any money donated beyond the minimum amount needed to pay the expenses of his trip was given to him as an honorarium for his talks. (He never requested or required it, but it was obviously the first-best thing we could have done with the surplusses.) My calls-for-donations would include this information, including what was to be done with surplusses, and I would issue a receipt for any donation I received. (Sometimes this didn't happen, because at any given Damian-talk event a bunch of people would just run up to me, stuff a $20 in my hand, and then run away (even as I yelled after them that I wanted to give them a receipt)). I also provided Damian with a list of all donors + their email addresses, as he wanted to send them off personal thanks afterwards. Mix of personal vs. corporation donations --> I would say that it leaned very heavily to personal donations. In fact, it was 100% personal... except to the extent that some individual Toronto Mongers would operate as their own corporations when making donations. Perhaps I could have solicited donations from Bigger Companies, but it was never necessary to do so in order to get Damian's budget covered. Like I said before, $1500 was always pretty easy to get in individual donations from Toronto Mongers. Things became more difficult once he stopped coming to N. America for YAPC::NA. This is because his now-squeezed travel itineary meant there was only about 4 weeks between OSCON and YAPC::EU, and so almost all of those weeks he would have corporate training engagements, either in N. America or in Europe. That made fitting "side trips" into his schedule almost impossible. So, my approach at that point was to network around in Toronto to see if I could find a company that was willing to *be* one of those corporate training gigs for Damian. Sometimes it would work, sometimes it wouldn't. If it worked then Damian would travel to Toronto for the corporate training engagement, and either stay a few extra days (over a weekend probably) to provide a free public talk or two, or he would do a public talk in the evening following a corporate training day. So in one sense this made things easier, as the budget required for Damian was lowered -- the corporate training gig would pay for the airfare and hotel on the nights of training days. But there was still a hotel, meals, etc. budget needed for whatever extra days Damian would be in town. But the extra work I had to go through to find corporate training for him was *much* harder than the effort involved in soliciting donations from the ever-ultra-generous Mongers. So... If you can find him corporate training opportunities, that will almost guarantee his being able to come to Boston to give some public talks too. :-) Otherwise, you're at the mercy of his training schedule, and donations-from-Mongers, while necessary, possibly won't be sufficient to get a trip out of him. I hope this is helpful insight. If there are other questions I can answer please ask away. Cheers, - Richard On Sun, Mar 6, 2011 at 12:53 PM, alexmac131 at hotmail.com < alexmac131 at hotmail.com> wrote: > put me down for donation call if you want to bring him here. will toss in > 300 > > Sent from the Viking 2 Lander > > > On 2011-03-06, at 10:10 AM, Tom Legrady wrote: > > If he comes as close as Boston, can we get him to Toronto? I's been years > > On Sun, Mar 6, 2011 at 1:35 AM, Uri Guttman < > uri at stemsystems.com> wrote: > >> >> hi all, >> >> i know in the past you brought damian conway to toronto by collecting >> funds to cover a side trip there during his NA tour. i would like to >> organize a similar thing for boston so i would like some info on how you >> did it. what was the budget for the visit? how did you collect the >> money? what was the mix from companies vs individuals? any other info >> you can send me would be great. we have had damian talk in boston before >> but that was always when he was already in town doing training. this >> would be our first time trying to get him to make a side trip. >> >> thanx, >> >> uri >> >> -- >> Uri Guttman ------ uri at stemsystems.com -------- >> http://www.sysarch.com -- >> ----- Perl Code Review , Architecture, Development, Training, Support >> ------ >> --------- Gourmet Hot Cocoa Mix ---- >> http://bestfriendscocoa.com --------- >> _______________________________________________ >> toronto-pm mailing list >> toronto-pm at pm.org >> >> http://mail.pm.org/mailman/listinfo/toronto-pm >> > > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm > > > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From arocker at Vex.Net Mon Mar 7 07:48:41 2011 From: arocker at Vex.Net (arocker at Vex.Net) Date: Mon, 7 Mar 2011 10:48:41 -0500 Subject: [tpm] Last month's meeting Message-ID: Did it reveal any impending jobs? I'm looking for a new contract. From fulko.hew at gmail.com Wed Mar 9 08:15:30 2011 From: fulko.hew at gmail.com (Fulko Hew) Date: Wed, 9 Mar 2011 11:15:30 -0500 Subject: [tpm] I wish I was better at regex's Message-ID: Today's regex problem is a standard problem, that has standard answers, I just don't know them, and I haven't found them... "Strip comments from lines while obeying quoted strings". I've got a fellow who's dealing with 'registry files', but needs to strip comments off of the end of the lines (I.e. anything after a semicolon) but preserve semicolons (and text) if found within a quoted string. I know there are hard ways to do it, but there's got to be a module to handle it for me. Here are some example strings: key="value" key=value key="value1;value2" key="value1;value2" ; comment key='value1;value2' ; comment "key"="value1" "key"="value1" ; comment "key"="value1;value2" "key"="value1;value2" ; comment "key"="val\"ue1;value2" "key"="val\"ue1;value2" ; comment "key"='val\'ue1;value2' ; comment "key"='val\"ue1;value2' ; comment Suggestions? Fulko -------------- next part -------------- An HTML attachment was scrubbed... URL: From janes.rob at gmail.com Wed Mar 9 09:07:43 2011 From: janes.rob at gmail.com (Rob Janes) Date: Wed, 9 Mar 2011 12:07:43 -0500 Subject: [tpm] I wish I was better at regex's In-Reply-To: References: Message-ID: seems to work ... #!/usr/bin/env perl while (<>) { chomp; print "\n\n================\nline: $_\n"; if (m{ ^ ( (?:[^=\\"';\s]| \\.| "(?:[^"\\]|\\.)*"| '(?:[^'\\]|\\.)*' )+ ) \s* = \s* ( (?:[^=\\"';\s]| \\.| "(?:[^"\\]|\\.)*"| '(?:[^'\\]|\\.)*' )+ ) (?:\s*;\s*(.*))? $ }x) { print "matches!\n"; print "key is $1\nvalue is $2\ncomment is $3\n"; } else { print "match FAILED!\n"; } } results: ================ line: key="value" matches! key is key value is "value" comment is ================ line: key=value matches! key is key value is value comment is ================ line: key="value1;value2" matches! key is key value is "value1;value2" comment is ================ line: key="value1;value2" ; comment matches! key is key value is "value1;value2" comment is comment ================ line: key='value1;value2' ; comment matches! key is key value is 'value1;value2' comment is comment ================ line: "key"="value1" matches! key is "key" value is "value1" comment is ================ line: "key"="value1" ; comment matches! key is "key" value is "value1" comment is comment ================ line: "key"="value1;value2" matches! key is "key" value is "value1;value2" comment is ================ line: "key"="value1;value2" ; comment matches! key is "key" value is "value1;value2" comment is comment ================ line: "key"="val\"ue1;value2" matches! key is "key" value is "val\"ue1;value2" comment is ================ line: "key"="val\"ue1;value2" ; comment matches! key is "key" value is "val\"ue1;value2" comment is comment ================ line: "key"='val\'ue1;value2' ; comment matches! key is "key" value is 'val\'ue1;value2' comment is comment ================ line: "key"='val\"ue1;value2' ; comment matches! key is "key" value is 'val\"ue1;value2' comment is comment On Wed, Mar 9, 2011 at 11:15 AM, Fulko Hew wrote: > Today's regex problem is a standard problem, that has standard answers, > I just don't know them, and I haven't found them... > > "Strip comments from lines while obeying quoted strings". > > I've got a fellow who's dealing with 'registry files', but needs to > strip comments off of the end of the lines (I.e. anything after a semicolon) > but preserve semicolons (and text) if found within a quoted string. > > I know there are hard ways to do it, but there's got to be a module > to handle it for me. > > Here are some example strings: > > key="value" > key=value > key="value1;value2" > key="value1;value2" ??? ; comment > key='value1;value2' ? ? ; comment > "key"="value1" > "key"="value1" ? ? ? ?? ; comment > "key"="value1;value2" > "key"="value1;value2" ? ; comment > "key"="val\"ue1;value2" > "key"="val\"ue1;value2" ; comment > "key"='val\'ue1;value2' ; comment > "key"='val\"ue1;value2' ; comment > > > Suggestions? > > Fulko > > > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm > > From janes.rob at gmail.com Wed Mar 9 10:14:58 2011 From: janes.rob at gmail.com (Rob Janes) Date: Wed, 9 Mar 2011 13:14:58 -0500 Subject: [tpm] I wish I was better at regex's In-Reply-To: References: Message-ID: here's one that dequotes the key and value ... #!/usr/bin/env perl use strict; use warnings; sub dequote($) { my $quoted = $_[0]; my $dequoted = ""; my $counter = 0; while ($quoted =~ m{ ( (?:[^=\\"';\s]| \\.| "(?:[^"\\]|\\.)*"| '(?:[^'\\]|\\.)*' ) ) }gx) { my $piece = $1; if (substr($piece, 0, 1) eq '\\') { $dequoted .= substr($piece, 1, 1); } elsif (substr($piece, 0, 1) eq '"' || substr($piece, 0, 1,) eq "'") { my $temp = substr($piece, 1, -1); $temp =~ s/\\(.)/$1/g; $dequoted .= $temp; } else { $dequoted .= $piece; } $counter++; } $_[0] = $dequoted if $counter; return $counter; } while (<>) { chomp; print "\n\n================\nline: $_\n"; if (m{ ^ ( (?:[^=\\"';\s]| \\.| "(?:[^"\\]|\\.)*"| '(?:[^'\\]|\\.)*' )+ ) \s* = \s* ( (?:[^=\\"';\s]| \\.| "(?:[^"\\]|\\.)*"| '(?:[^'\\]|\\.)*' )+ ) (?:\s*;\s*(.*))? $ }x) { my ($key, $value, $comment) = ($1, $2, $3); print "matches!\n"; dequote($key); dequote($value); print "key is $key\nvalue is $value\ncomment is $comment\n"; } else { print "match FAILED!\n"; } } and the output is ... ================ line: key="value" matches! key is key value is value comment is ================ line: key=value matches! key is key value is value comment is ================ line: key="value1;value2" matches! key is key value is value1;value2 comment is ================ line: key="value1;value2" ; comment matches! key is key value is value1;value2 comment is comment ================ line: key='value1;value2' ; comment matches! key is key value is value1;value2 comment is comment ================ line: "key"="value1" matches! key is key value is value1 comment is ================ line: "key"="value1" ; comment matches! key is key value is value1 comment is comment ================ line: "key"="value1;value2" matches! key is key value is value1;value2 comment is ================ line: "key"="value1;value2" ; comment matches! key is key value is value1;value2 comment is comment ================ line: "key"="val\"ue1;value2" matches! key is key value is val"ue1;value2 comment is ================ line: "key"="val\"ue1;value2" ; comment matches! key is key value is val"ue1;value2 comment is comment ================ line: "key"='val\'ue1;value2' ; comment matches! key is key value is val'ue1;value2 comment is comment ================ line: "key"='val\"ue1;value2' ; comment matches! key is key value is val"ue1;value2 comment is comment On Wed, Mar 9, 2011 at 12:07 PM, Rob Janes wrote: > seems to work ... > > #!/usr/bin/env perl > > while (<>) { > ?chomp; > > ?print "\n\n================\nline: $_\n"; > > ?if (m{ > ? ? ? ?^ > ? ? ? ?( > ? ? ? ? ?(?:[^=\\"';\s]| > ? ? ? ? ? ?\\.| > ? ? ? ? ? ?"(?:[^"\\]|\\.)*"| > ? ? ? ? ? ?'(?:[^'\\]|\\.)*' > ? ? ? ? ?)+ > ? ? ? ?) > ? ? ? ? \s* = \s* > ? ? ? ?( > ? ? ? ? ?(?:[^=\\"';\s]| > ? ? ? ? ? ?\\.| > ? ? ? ? ? ?"(?:[^"\\]|\\.)*"| > ? ? ? ? ? ?'(?:[^'\\]|\\.)*' > ? ? ? ? ? ?)+ > ? ? ? ?) > ? ? ? ?(?:\s*;\s*(.*))? > ? ? ? ?$ > ? ? ? ?}x) > ?{ > ? ? print "matches!\n"; > ? ? print "key is $1\nvalue is $2\ncomment is $3\n"; > ?} > ?else > ?{ > ? ? print "match FAILED!\n"; > ?} > } > > results: > > ================ > line: key="value" > matches! > key is key > value is "value" > comment is > > > ================ > line: key=value > matches! > key is key > value is value > comment is > > > ================ > line: key="value1;value2" > matches! > key is key > value is "value1;value2" > comment is > > > ================ > line: key="value1;value2" ? ? ; comment > matches! > key is key > value is "value1;value2" > comment is comment > > > ================ > line: key='value1;value2' ? ? ; comment > matches! > key is key > value is 'value1;value2' > comment is comment > > > ================ > line: "key"="value1" > matches! > key is "key" > value is "value1" > comment is > > > ================ > line: "key"="value1" ? ? ? ? ?; comment > matches! > key is "key" > value is "value1" > comment is comment > > > ================ > line: "key"="value1;value2" > matches! > key is "key" > value is "value1;value2" > comment is > > > ================ > line: "key"="value1;value2" ? ; comment > matches! > key is "key" > value is "value1;value2" > comment is comment > > > ================ > line: "key"="val\"ue1;value2" > matches! > key is "key" > value is "val\"ue1;value2" > comment is > > > ================ > line: "key"="val\"ue1;value2" ; comment > matches! > key is "key" > value is "val\"ue1;value2" > comment is comment > > > ================ > line: "key"='val\'ue1;value2' ; comment > matches! > key is "key" > value is 'val\'ue1;value2' > comment is comment > > > ================ > line: "key"='val\"ue1;value2' ; comment > matches! > key is "key" > value is 'val\"ue1;value2' > comment is comment > > > On Wed, Mar 9, 2011 at 11:15 AM, Fulko Hew wrote: >> Today's regex problem is a standard problem, that has standard answers, >> I just don't know them, and I haven't found them... >> >> "Strip comments from lines while obeying quoted strings". >> >> I've got a fellow who's dealing with 'registry files', but needs to >> strip comments off of the end of the lines (I.e. anything after a semicolon) >> but preserve semicolons (and text) if found within a quoted string. >> >> I know there are hard ways to do it, but there's got to be a module >> to handle it for me. >> >> Here are some example strings: >> >> key="value" >> key=value >> key="value1;value2" >> key="value1;value2" ??? ; comment >> key='value1;value2' ? ? ; comment >> "key"="value1" >> "key"="value1" ? ? ? ?? ; comment >> "key"="value1;value2" >> "key"="value1;value2" ? ; comment >> "key"="val\"ue1;value2" >> "key"="val\"ue1;value2" ; comment >> "key"='val\'ue1;value2' ; comment >> "key"='val\"ue1;value2' ; comment >> >> >> Suggestions? >> >> Fulko >> >> >> _______________________________________________ >> toronto-pm mailing list >> toronto-pm at pm.org >> http://mail.pm.org/mailman/listinfo/toronto-pm >> >> > From fulko.hew at gmail.com Wed Mar 9 10:39:44 2011 From: fulko.hew at gmail.com (Fulko Hew) Date: Wed, 9 Mar 2011 13:39:44 -0500 Subject: [tpm] I wish I was better at regex's In-Reply-To: References: Message-ID: On Wed, Mar 9, 2011 at 1:14 PM, Rob Janes wrote: > here's one that dequotes the key and value ... > Thanks for the ideas, but.. the issue isn't with extracting the keys and the values (and dequoting them), the task was only to strip trailing comments (while obeying quoted strings) -------------- next part -------------- An HTML attachment was scrubbed... URL: From sfryer at sourcery.ca Wed Mar 9 10:48:39 2011 From: sfryer at sourcery.ca (Shaun Fryer) Date: Wed, 9 Mar 2011 13:48:39 -0500 Subject: [tpm] I wish I was better at regex's In-Reply-To: References: Message-ID: my $strip = qr{;[^\;]+$}; while () { chomp; $_ =~ s/$strip//; print $_, "\n"; } __DATA__ key="value" key=value key="value1;value2" key="value1;value2" ; comment key='value1;value2' ; comment "key"="value1" "key"="value1" ; comment "key"="value1;value2" "key"="value1;value2" ; comment "key"="val\"ue1;value2" "key"="val\"ue1;value2" ; comment "key"='val\'ue1;value2' ; comment "key"='val\"ue1;value2' ; comment -- Shaun Fryer cell: 1-647-709-6509 voip: 1-647-723-2729 On Wed, Mar 9, 2011 at 1:39 PM, Fulko Hew wrote: > > On Wed, Mar 9, 2011 at 1:14 PM, Rob Janes wrote: >> >> here's one that dequotes the key and value ... > > Thanks for the ideas, but.. > the issue isn't with extracting the keys and the values (and dequoting > them), > the task was only to strip trailing comments (while obeying quoted strings) > > > > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm > > From fulko.hew at gmail.com Wed Mar 9 10:58:30 2011 From: fulko.hew at gmail.com (Fulko Hew) Date: Wed, 9 Mar 2011 13:58:30 -0500 Subject: [tpm] I wish I was better at regex's In-Reply-To: References: Message-ID: On Wed, Mar 9, 2011 at 1:48 PM, Shaun Fryer wrote: > my $strip = qr{;[^\;]+$}; > while () { > chomp; > $_ =~ s/$strip//; > print $_, "\n"; > } > Congratulations Shaun, you win the prize! (a free beer at the next meeting), but. can you explain it to me? and why it manages to avoid quotes; I don't see how it does what it does. ... just another sign that is time to retire :-( -------------- next part -------------- An HTML attachment was scrubbed... URL: From sfryer at sourcery.ca Wed Mar 9 11:02:15 2011 From: sfryer at sourcery.ca (Shaun Fryer) Date: Wed, 9 Mar 2011 14:02:15 -0500 Subject: [tpm] I wish I was better at regex's In-Reply-To: References: Message-ID: actually, it doesn't work. there're a few I didn't notice which get truncated... still working on it. interesting problem... :) -- Shaun Fryer cell: 1-647-709-6509 voip: 1-647-723-2729 On Wed, Mar 9, 2011 at 1:58 PM, Fulko Hew wrote: > > > On Wed, Mar 9, 2011 at 1:48 PM, Shaun Fryer wrote: >> >> my $strip = qr{;[^\;]+$}; >> while () { >> ? ?chomp; >> ? ?$_ =~ s/$strip//; >> ? ?print $_, "\n"; >> } > > Congratulations Shaun, you win the prize! (a free beer at the next meeting), > but. > can you explain it to me? and why it manages to avoid quotes; > I don't see how it does what it does. > ... just another sign that is time to retire :-( > > > From janes.rob at gmail.com Wed Mar 9 11:11:30 2011 From: janes.rob at gmail.com (Rob Janes) Date: Wed, 9 Mar 2011 14:11:30 -0500 Subject: [tpm] I wish I was better at regex's In-Reply-To: References: Message-ID: except key="value1;value2" comes out as key="value1 and "key"="value1;value2" comes out as "key"="value1 this is the case where there is no comment, but there is a ; inside the value or key. i really don't think there's any short way to do this, unless you don't care about stuff like this. -rob On Wed, Mar 9, 2011 at 1:48 PM, Shaun Fryer wrote: > my $strip = qr{;[^\;]+$}; > while () { > ? ?chomp; > ? ?$_ =~ s/$strip//; > ? ?print $_, "\n"; > } > > __DATA__ > key="value" > key=value > key="value1;value2" > key="value1;value2" ? ? ; comment > key='value1;value2' ? ? ; comment > "key"="value1" > "key"="value1" ? ? ? ? ?; comment > "key"="value1;value2" > "key"="value1;value2" ? ; comment > "key"="val\"ue1;value2" > "key"="val\"ue1;value2" ; comment > "key"='val\'ue1;value2' ; comment > "key"='val\"ue1;value2' ; comment > > -- > Shaun Fryer > cell: 1-647-709-6509 > voip: 1-647-723-2729 > > > > > On Wed, Mar 9, 2011 at 1:39 PM, Fulko Hew wrote: >> >> On Wed, Mar 9, 2011 at 1:14 PM, Rob Janes wrote: >>> >>> here's one that dequotes the key and value ... >> >> Thanks for the ideas, but.. >> the issue isn't with extracting the keys and the values (and dequoting >> them), >> the task was only to strip trailing comments (while obeying quoted strings) >> >> >> >> _______________________________________________ >> toronto-pm mailing list >> toronto-pm at pm.org >> http://mail.pm.org/mailman/listinfo/toronto-pm >> >> > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm > From daniel at benoy.name Wed Mar 9 11:12:47 2011 From: daniel at benoy.name (daniel at benoy.name) Date: Wed, 09 Mar 2011 14:12:47 -0500 Subject: [tpm] I wish I was better at regex's In-Reply-To: References: Message-ID: Doesn't work. Output: ---- key="value" key=value key="value1 key="value1;value2" key='value1;value2' "key"="value1" "key"="value1" "key"="value1 "key"="value1;value2" "key"="val\"ue1 "key"="val\"ue1;value2" "key"='val\'ue1;value2' "key"='val\"ue1;value2' ---- Look at line 3. Also it wouldn't catch a trailing semicolon with nothing after it. Here's a quick and dirty improvement, but it will still have problems: my $strip = qr{;[^\;\"\']*$}; while () { chomp; $_ =~ s/$strip//; print $_, "\n"; } Here's the way I would do it: ---- while () { chomp; my $stripped; my $quotechar = ""; foreach my $char (split(//, $_)) { if ($quotechar) { # We're currently quoted if ($char eq $quotechar) { # end of quote $quotechar = ""; } } else { # We're not currently quoted if ($char eq ';') { # The comment has begun! last(); } elsif ($char eq '"' || $char eq "'") { # start of quote $quotechar = $char; } } $stripped .= $char; } print "$stripped\n"; } __DATA__ key="value" key=value key="value1;value2" key="value1;value2" ; comment key='value1;value2' ; comment "key"="value1" "key"="value1" ; comment "key"="value1;value2" "key"="value1;value2" ; comment "key"="val\"ue1;value2" "key"="val\"ue1;value2" ; comment "key"='val\'ue1;value2' ; comment "key"='val\"ue1;value2' ; comment ---- On Wed, 9 Mar 2011 13:48:39 -0500, Shaun Fryer wrote: > my $strip = qr{;[^\;]+$}; > while () { > chomp; > $_ =~ s/$strip//; > print $_, "\n"; > } > > __DATA__ > key="value" > key=value > key="value1;value2" > key="value1;value2" ; comment > key='value1;value2' ; comment > "key"="value1" > "key"="value1" ; comment > "key"="value1;value2" > "key"="value1;value2" ; comment > "key"="val\"ue1;value2" > "key"="val\"ue1;value2" ; comment > "key"='val\'ue1;value2' ; comment > "key"='val\"ue1;value2' ; comment > > -- > Shaun Fryer > cell: 1-647-709-6509 > voip: 1-647-723-2729 > > > > > On Wed, Mar 9, 2011 at 1:39 PM, Fulko Hew > wrote: >> >> On Wed, Mar 9, 2011 at 1:14 PM, Rob Janes >> wrote: >>> >>> here's one that dequotes the key and value ... >> >> Thanks for the ideas, but.. >> the issue isn't with extracting the keys and the values (and >> dequoting >> them), >> the task was only to strip trailing comments (while obeying quoted >> strings) >> >> >> >> _______________________________________________ >> toronto-pm mailing list >> toronto-pm at pm.org >> http://mail.pm.org/mailman/listinfo/toronto-pm >> >> > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm From daniel at benoy.name Wed Mar 9 11:15:52 2011 From: daniel at benoy.name (daniel at benoy.name) Date: Wed, 09 Mar 2011 14:15:52 -0500 Subject: [tpm] I wish I was better at regex's In-Reply-To: References: Message-ID: <7d4ae0e152f2747e6a745d3a43b3157e@benoy.name> I didn't notice that you wanted to handle escaped quotes as well, but that method can probably be quickly adapted for that. Good luck. On Wed, 09 Mar 2011 14:12:47 -0500, daniel at benoy.name wrote: > Doesn't work. Output: > > ---- > key="value" > key=value > key="value1 > key="value1;value2" > key='value1;value2' > "key"="value1" > "key"="value1" > "key"="value1 > "key"="value1;value2" > "key"="val\"ue1 > "key"="val\"ue1;value2" > "key"='val\'ue1;value2' > "key"='val\"ue1;value2' > ---- > > Look at line 3. > > Also it wouldn't catch a trailing semicolon with nothing after it. > > Here's a quick and dirty improvement, but it will still have > problems: > > my $strip = qr{;[^\;\"\']*$}; > while () { > chomp; > $_ =~ s/$strip//; > print $_, "\n"; > } > > > Here's the way I would do it: > > ---- > while () { > chomp; > > my $stripped; > my $quotechar = ""; > foreach my $char (split(//, $_)) { > if ($quotechar) { # We're currently quoted > if ($char eq $quotechar) { # end of quote > $quotechar = ""; > } > } else { # We're not currently quoted > if ($char eq ';') { # The comment has begun! > last(); > } elsif ($char eq '"' || $char eq "'") { # start of quote > $quotechar = $char; > } > } > $stripped .= $char; > } > print "$stripped\n"; > } > > __DATA__ > key="value" > key=value > key="value1;value2" > key="value1;value2" ; comment > key='value1;value2' ; comment > "key"="value1" > "key"="value1" ; comment > "key"="value1;value2" > "key"="value1;value2" ; comment > "key"="val\"ue1;value2" > "key"="val\"ue1;value2" ; comment > "key"='val\'ue1;value2' ; comment > "key"='val\"ue1;value2' ; comment > ---- > > On Wed, 9 Mar 2011 13:48:39 -0500, Shaun Fryer wrote: >> my $strip = qr{;[^\;]+$}; >> while () { >> chomp; >> $_ =~ s/$strip//; >> print $_, "\n"; >> } >> >> __DATA__ >> key="value" >> key=value >> key="value1;value2" >> key="value1;value2" ; comment >> key='value1;value2' ; comment >> "key"="value1" >> "key"="value1" ; comment >> "key"="value1;value2" >> "key"="value1;value2" ; comment >> "key"="val\"ue1;value2" >> "key"="val\"ue1;value2" ; comment >> "key"='val\'ue1;value2' ; comment >> "key"='val\"ue1;value2' ; comment >> >> -- >> Shaun Fryer >> cell: 1-647-709-6509 >> voip: 1-647-723-2729 >> >> >> >> >> On Wed, Mar 9, 2011 at 1:39 PM, Fulko Hew >> wrote: >>> >>> On Wed, Mar 9, 2011 at 1:14 PM, Rob Janes >>> wrote: >>>> >>>> here's one that dequotes the key and value ... >>> >>> Thanks for the ideas, but.. >>> the issue isn't with extracting the keys and the values (and >>> dequoting >>> them), >>> the task was only to strip trailing comments (while obeying quoted >>> strings) >>> >>> >>> >>> _______________________________________________ >>> toronto-pm mailing list >>> toronto-pm at pm.org >>> http://mail.pm.org/mailman/listinfo/toronto-pm >>> >>> >> _______________________________________________ >> toronto-pm mailing list >> toronto-pm at pm.org >> http://mail.pm.org/mailman/listinfo/toronto-pm > > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm From sfryer at sourcery.ca Wed Mar 9 11:16:16 2011 From: sfryer at sourcery.ca (Shaun Fryer) Date: Wed, 9 Mar 2011 14:16:16 -0500 Subject: [tpm] I wish I was better at regex's In-Reply-To: References: Message-ID: my $strip = qr{;[^\;]+$}; while () { chomp; my ($key, $val) = split /=/; my ($quote) = ($val =~ m{^(["'])}g); if ($quote) { ($val) = ($val =~ m{^($quote[^\b]+($quote))}g); } else { $val =~ s/$strip//; } print $key, '=', $val, "\n"; } __DATA__ key="value" key=value key="vlue;" key="value1;value2" key="value1;value2" ; comment key='value1;value2' ; comment "key"="value1" "key"="value1" ; comment "key"="value1;value2" "key"="value1;value2" ; comment "key"="val\"ue1;value2" "key"="val\"ue1;value2" ; comment "key"='val\'ue1;value2' ; comment "key"='val\"ue1;value2' ; comment -- Shaun Fryer cell: 1-647-709-6509 voip: 1-647-723-2729 On Wed, Mar 9, 2011 at 2:12 PM, wrote: > Doesn't work. ?Output: > > ---- > key="value" > key=value > key="value1 > key="value1;value2" > key='value1;value2' > "key"="value1" > "key"="value1" > "key"="value1 > "key"="value1;value2" > "key"="val\"ue1 > "key"="val\"ue1;value2" > "key"='val\'ue1;value2' > "key"='val\"ue1;value2' > ---- > > Look at line 3. > > Also it wouldn't catch a trailing semicolon with nothing after it. > > Here's a quick and dirty improvement, but it will still have problems: > > my $strip = qr{;[^\;\"\']*$}; > while () { > ? ?chomp; > ? ?$_ =~ s/$strip//; > ? ?print $_, "\n"; > } > > > Here's the way I would do it: > > ---- > while () { > ? ?chomp; > > ? ?my $stripped; > ? ?my $quotechar = ""; > ? ?foreach my $char (split(//, $_)) { > ? ? ? ?if ($quotechar) { # We're currently quoted > ? ? ? ? ? ?if ($char eq $quotechar) { # end of quote > ? ? ? ? ? ? ? ?$quotechar = ""; > ? ? ? ? ? ?} > ? ? ? ?} else { # We're not currently quoted > ? ? ? ? ? ?if ($char eq ';') { # The comment has begun! > ? ? ? ? ? ? ? ?last(); > ? ? ? ? ? ?} elsif ($char eq '"' || $char eq "'") { # start of quote > ? ? ? ? ? ? ? ?$quotechar = $char; > ? ? ? ? ? ?} > ? ? ? ?} > ? ? ? ?$stripped .= $char; > ? ?} > ? ?print "$stripped\n"; > } > > __DATA__ > key="value" > key=value > key="value1;value2" > key="value1;value2" ? ? ; comment > key='value1;value2' ? ? ; comment > "key"="value1" > "key"="value1" ? ? ? ? ?; comment > "key"="value1;value2" > "key"="value1;value2" ? ; comment > "key"="val\"ue1;value2" > "key"="val\"ue1;value2" ; comment > "key"='val\'ue1;value2' ; comment > "key"='val\"ue1;value2' ; comment > ---- > > On Wed, 9 Mar 2011 13:48:39 -0500, Shaun Fryer wrote: >> >> my $strip = qr{;[^\;]+$}; >> while () { >> ? ?chomp; >> ? ?$_ =~ s/$strip//; >> ? ?print $_, "\n"; >> } >> >> __DATA__ >> key="value" >> key=value >> key="value1;value2" >> key="value1;value2" ? ? ; comment >> key='value1;value2' ? ? ; comment >> "key"="value1" >> "key"="value1" ? ? ? ? ?; comment >> "key"="value1;value2" >> "key"="value1;value2" ? ; comment >> "key"="val\"ue1;value2" >> "key"="val\"ue1;value2" ; comment >> "key"='val\'ue1;value2' ; comment >> "key"='val\"ue1;value2' ; comment >> >> -- >> Shaun Fryer >> cell: 1-647-709-6509 >> voip: 1-647-723-2729 >> >> >> >> >> On Wed, Mar 9, 2011 at 1:39 PM, Fulko Hew wrote: >>> >>> On Wed, Mar 9, 2011 at 1:14 PM, Rob Janes wrote: >>>> >>>> here's one that dequotes the key and value ... >>> >>> Thanks for the ideas, but.. >>> the issue isn't with extracting the keys and the values (and dequoting >>> them), >>> the task was only to strip trailing comments (while obeying quoted >>> strings) >>> >>> >>> >>> _______________________________________________ >>> toronto-pm mailing list >>> toronto-pm at pm.org >>> http://mail.pm.org/mailman/listinfo/toronto-pm >>> >>> >> _______________________________________________ >> toronto-pm mailing list >> toronto-pm at pm.org >> http://mail.pm.org/mailman/listinfo/toronto-pm > > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm > From fulko.hew at gmail.com Wed Mar 9 11:25:09 2011 From: fulko.hew at gmail.com (Fulko Hew) Date: Wed, 9 Mar 2011 14:25:09 -0500 Subject: [tpm] I wish I was better at regex's In-Reply-To: References: Message-ID: On Wed, Mar 9, 2011 at 2:16 PM, Shaun Fryer wrote: > my $strip = qr{;[^\;]+$}; > while () { > chomp; > my ($key, $val) = split /=/; > my ($quote) = ($val =~ m{^(["'])}g); > if ($quote) { > ($val) = ($val =~ m{^($quote[^\b]+($quote))}g); > } > else { > $val =~ s/$strip//; > } > print $key, '=', $val, "\n"; > } > Closer, but it still assumes the key=value concept, the goal was 'any trailing comment' (not quoted) ie. regardless of the syntax before it as in the following additional test case: title ;comment -------------- next part -------------- An HTML attachment was scrubbed... URL: From sfryer at sourcery.ca Wed Mar 9 11:29:04 2011 From: sfryer at sourcery.ca (Shaun Fryer) Date: Wed, 9 Mar 2011 14:29:04 -0500 Subject: [tpm] I wish I was better at regex's In-Reply-To: References: Message-ID: It's very difficult to do without matching quotes, and hence key/value pairs. For instance, what if the comment contains a quote, just as the quotes may contain a semi-colon? In this case I've sidestepped the problem of escaped quotes by using a word-boundary (\b) match inside any matched quotes. the side effect of this, is that any spaces inside the quotes will count... good luck if you can do it without matching keys/values/quotes. I've already got beers riding on the solution. ;) -- Shaun Fryer cell: 1-647-709-6509 voip: 1-647-723-2729 On Wed, Mar 9, 2011 at 2:25 PM, Fulko Hew wrote: > > > On Wed, Mar 9, 2011 at 2:16 PM, Shaun Fryer wrote: >> >> my $strip = qr{;[^\;]+$}; >> while () { >> ? ?chomp; >> ? ?my ($key, $val) = split /=/; >> ? ?my ($quote) = ($val =~ m{^(["'])}g); >> ? ?if ($quote) { >> ? ? ? ?($val) = ($val =~ m{^($quote[^\b]+($quote))}g); >> ? ?} >> ? ?else { >> ? ? ? ?$val =~ s/$strip//; >> ? ?} >> ? ?print $key, '=', $val, "\n"; >> } > > Closer, but it still assumes the key=value concept, > the goal was? 'any trailing comment' (not quoted) ie. regardless of the > syntax before it > as in the following additional test case: > > title ;comment > > From janes.rob at gmail.com Wed Mar 9 11:30:06 2011 From: janes.rob at gmail.com (Rob Janes) Date: Wed, 9 Mar 2011 14:30:06 -0500 Subject: [tpm] I wish I was better at regex's In-Reply-To: References: Message-ID: there's key="this=that" ; an = in the value and key="value" ; a " in the comment On Wed, Mar 9, 2011 at 2:16 PM, Shaun Fryer wrote: > my $strip = qr{;[^\;]+$}; > while () { > ? ?chomp; > ? ?my ($key, $val) = split /=/; > ? ?my ($quote) = ($val =~ m{^(["'])}g); > ? ?if ($quote) { > ? ? ? ?($val) = ($val =~ m{^($quote[^\b]+($quote))}g); > ? ?} > ? ?else { > ? ? ? ?$val =~ s/$strip//; > ? ?} > ? ?print $key, '=', $val, "\n"; > } > > __DATA__ > key="value" > key=value > key="vlue;" > key="value1;value2" > key="value1;value2" ? ? ; comment > key='value1;value2' ? ? ; comment > "key"="value1" > "key"="value1" ? ? ? ? ?; comment > "key"="value1;value2" > "key"="value1;value2" ? ; comment > "key"="val\"ue1;value2" > "key"="val\"ue1;value2" ; comment > "key"='val\'ue1;value2' ; comment > "key"='val\"ue1;value2' ; comment > -- > Shaun Fryer > cell: 1-647-709-6509 > voip: 1-647-723-2729 > > > > > On Wed, Mar 9, 2011 at 2:12 PM, ? wrote: >> Doesn't work. ?Output: >> >> ---- >> key="value" >> key=value >> key="value1 >> key="value1;value2" >> key='value1;value2' >> "key"="value1" >> "key"="value1" >> "key"="value1 >> "key"="value1;value2" >> "key"="val\"ue1 >> "key"="val\"ue1;value2" >> "key"='val\'ue1;value2' >> "key"='val\"ue1;value2' >> ---- >> >> Look at line 3. >> >> Also it wouldn't catch a trailing semicolon with nothing after it. >> >> Here's a quick and dirty improvement, but it will still have problems: >> >> my $strip = qr{;[^\;\"\']*$}; >> while () { >> ? ?chomp; >> ? ?$_ =~ s/$strip//; >> ? ?print $_, "\n"; >> } >> >> >> Here's the way I would do it: >> >> ---- >> while () { >> ? ?chomp; >> >> ? ?my $stripped; >> ? ?my $quotechar = ""; >> ? ?foreach my $char (split(//, $_)) { >> ? ? ? ?if ($quotechar) { # We're currently quoted >> ? ? ? ? ? ?if ($char eq $quotechar) { # end of quote >> ? ? ? ? ? ? ? ?$quotechar = ""; >> ? ? ? ? ? ?} >> ? ? ? ?} else { # We're not currently quoted >> ? ? ? ? ? ?if ($char eq ';') { # The comment has begun! >> ? ? ? ? ? ? ? ?last(); >> ? ? ? ? ? ?} elsif ($char eq '"' || $char eq "'") { # start of quote >> ? ? ? ? ? ? ? ?$quotechar = $char; >> ? ? ? ? ? ?} >> ? ? ? ?} >> ? ? ? ?$stripped .= $char; >> ? ?} >> ? ?print "$stripped\n"; >> } >> >> __DATA__ >> key="value" >> key=value >> key="value1;value2" >> key="value1;value2" ? ? ; comment >> key='value1;value2' ? ? ; comment >> "key"="value1" >> "key"="value1" ? ? ? ? ?; comment >> "key"="value1;value2" >> "key"="value1;value2" ? ; comment >> "key"="val\"ue1;value2" >> "key"="val\"ue1;value2" ; comment >> "key"='val\'ue1;value2' ; comment >> "key"='val\"ue1;value2' ; comment >> ---- >> >> On Wed, 9 Mar 2011 13:48:39 -0500, Shaun Fryer wrote: >>> >>> my $strip = qr{;[^\;]+$}; >>> while () { >>> ? ?chomp; >>> ? ?$_ =~ s/$strip//; >>> ? ?print $_, "\n"; >>> } >>> >>> __DATA__ >>> key="value" >>> key=value >>> key="value1;value2" >>> key="value1;value2" ? ? ; comment >>> key='value1;value2' ? ? ; comment >>> "key"="value1" >>> "key"="value1" ? ? ? ? ?; comment >>> "key"="value1;value2" >>> "key"="value1;value2" ? ; comment >>> "key"="val\"ue1;value2" >>> "key"="val\"ue1;value2" ; comment >>> "key"='val\'ue1;value2' ; comment >>> "key"='val\"ue1;value2' ; comment >>> >>> -- >>> Shaun Fryer >>> cell: 1-647-709-6509 >>> voip: 1-647-723-2729 >>> >>> >>> >>> >>> On Wed, Mar 9, 2011 at 1:39 PM, Fulko Hew wrote: >>>> >>>> On Wed, Mar 9, 2011 at 1:14 PM, Rob Janes wrote: >>>>> >>>>> here's one that dequotes the key and value ... >>>> >>>> Thanks for the ideas, but.. >>>> the issue isn't with extracting the keys and the values (and dequoting >>>> them), >>>> the task was only to strip trailing comments (while obeying quoted >>>> strings) >>>> >>>> >>>> >>>> _______________________________________________ >>>> toronto-pm mailing list >>>> toronto-pm at pm.org >>>> http://mail.pm.org/mailman/listinfo/toronto-pm >>>> >>>> >>> _______________________________________________ >>> toronto-pm mailing list >>> toronto-pm at pm.org >>> http://mail.pm.org/mailman/listinfo/toronto-pm >> >> _______________________________________________ >> toronto-pm mailing list >> toronto-pm at pm.org >> http://mail.pm.org/mailman/listinfo/toronto-pm >> > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm > From fulko.hew at gmail.com Wed Mar 9 11:32:06 2011 From: fulko.hew at gmail.com (Fulko Hew) Date: Wed, 9 Mar 2011 14:32:06 -0500 Subject: [tpm] I wish I was better at regex's In-Reply-To: References: Message-ID: On Wed, Mar 9, 2011 at 2:29 PM, Shaun Fryer wrote: > > It's very difficult to do without matching quotes, and hence key/value > pairs. For instance, what if the comment contains a quote, just as the > quotes may contain a semi-colon? In this case I've sidestepped the > problem of escaped quotes by using a word-boundary (\b) match inside > any matched quotes. the side effect of this, is that any spaces inside > the quotes will count... > > good luck if you can do it without matching keys/values/quotes. I've > already got beers riding on the solution. ;) Thats why I then looked at things like: Regexp::Common::balanced Regexp::Common::comment but I couldn't figure out how to apply them. From sfryer at sourcery.ca Wed Mar 9 11:33:04 2011 From: sfryer at sourcery.ca (Shaun Fryer) Date: Wed, 9 Mar 2011 14:33:04 -0500 Subject: [tpm] I wish I was better at regex's In-Reply-To: References: Message-ID: Indeed. Or "key=\'stuff\'"="value1=\'stuff\',value2=\'more ;stuff\'" ; comment with " ' and ; -- Shaun Fryer cell: 1-647-709-6509 voip: 1-647-723-2729 On Wed, Mar 9, 2011 at 2:30 PM, Rob Janes wrote: > there's > > key="this=that" ?; an = in the value > > and > > key="value" ; a " in the comment > > On Wed, Mar 9, 2011 at 2:16 PM, Shaun Fryer wrote: >> my $strip = qr{;[^\;]+$}; >> while () { >> ? ?chomp; >> ? ?my ($key, $val) = split /=/; >> ? ?my ($quote) = ($val =~ m{^(["'])}g); >> ? ?if ($quote) { >> ? ? ? ?($val) = ($val =~ m{^($quote[^\b]+($quote))}g); >> ? ?} >> ? ?else { >> ? ? ? ?$val =~ s/$strip//; >> ? ?} >> ? ?print $key, '=', $val, "\n"; >> } >> >> __DATA__ >> key="value" >> key=value >> key="vlue;" >> key="value1;value2" >> key="value1;value2" ? ? ; comment >> key='value1;value2' ? ? ; comment >> "key"="value1" >> "key"="value1" ? ? ? ? ?; comment >> "key"="value1;value2" >> "key"="value1;value2" ? ; comment >> "key"="val\"ue1;value2" >> "key"="val\"ue1;value2" ; comment >> "key"='val\'ue1;value2' ; comment >> "key"='val\"ue1;value2' ; comment >> -- >> Shaun Fryer >> cell: 1-647-709-6509 >> voip: 1-647-723-2729 >> >> >> >> >> On Wed, Mar 9, 2011 at 2:12 PM, ? wrote: >>> Doesn't work. ?Output: >>> >>> ---- >>> key="value" >>> key=value >>> key="value1 >>> key="value1;value2" >>> key='value1;value2' >>> "key"="value1" >>> "key"="value1" >>> "key"="value1 >>> "key"="value1;value2" >>> "key"="val\"ue1 >>> "key"="val\"ue1;value2" >>> "key"='val\'ue1;value2' >>> "key"='val\"ue1;value2' >>> ---- >>> >>> Look at line 3. >>> >>> Also it wouldn't catch a trailing semicolon with nothing after it. >>> >>> Here's a quick and dirty improvement, but it will still have problems: >>> >>> my $strip = qr{;[^\;\"\']*$}; >>> while () { >>> ? ?chomp; >>> ? ?$_ =~ s/$strip//; >>> ? ?print $_, "\n"; >>> } >>> >>> >>> Here's the way I would do it: >>> >>> ---- >>> while () { >>> ? ?chomp; >>> >>> ? ?my $stripped; >>> ? ?my $quotechar = ""; >>> ? ?foreach my $char (split(//, $_)) { >>> ? ? ? ?if ($quotechar) { # We're currently quoted >>> ? ? ? ? ? ?if ($char eq $quotechar) { # end of quote >>> ? ? ? ? ? ? ? ?$quotechar = ""; >>> ? ? ? ? ? ?} >>> ? ? ? ?} else { # We're not currently quoted >>> ? ? ? ? ? ?if ($char eq ';') { # The comment has begun! >>> ? ? ? ? ? ? ? ?last(); >>> ? ? ? ? ? ?} elsif ($char eq '"' || $char eq "'") { # start of quote >>> ? ? ? ? ? ? ? ?$quotechar = $char; >>> ? ? ? ? ? ?} >>> ? ? ? ?} >>> ? ? ? ?$stripped .= $char; >>> ? ?} >>> ? ?print "$stripped\n"; >>> } >>> >>> __DATA__ >>> key="value" >>> key=value >>> key="value1;value2" >>> key="value1;value2" ? ? ; comment >>> key='value1;value2' ? ? ; comment >>> "key"="value1" >>> "key"="value1" ? ? ? ? ?; comment >>> "key"="value1;value2" >>> "key"="value1;value2" ? ; comment >>> "key"="val\"ue1;value2" >>> "key"="val\"ue1;value2" ; comment >>> "key"='val\'ue1;value2' ; comment >>> "key"='val\"ue1;value2' ; comment >>> ---- >>> >>> On Wed, 9 Mar 2011 13:48:39 -0500, Shaun Fryer wrote: >>>> >>>> my $strip = qr{;[^\;]+$}; >>>> while () { >>>> ? ?chomp; >>>> ? ?$_ =~ s/$strip//; >>>> ? ?print $_, "\n"; >>>> } >>>> >>>> __DATA__ >>>> key="value" >>>> key=value >>>> key="value1;value2" >>>> key="value1;value2" ? ? ; comment >>>> key='value1;value2' ? ? ; comment >>>> "key"="value1" >>>> "key"="value1" ? ? ? ? ?; comment >>>> "key"="value1;value2" >>>> "key"="value1;value2" ? ; comment >>>> "key"="val\"ue1;value2" >>>> "key"="val\"ue1;value2" ; comment >>>> "key"='val\'ue1;value2' ; comment >>>> "key"='val\"ue1;value2' ; comment >>>> >>>> -- >>>> Shaun Fryer >>>> cell: 1-647-709-6509 >>>> voip: 1-647-723-2729 >>>> >>>> >>>> >>>> >>>> On Wed, Mar 9, 2011 at 1:39 PM, Fulko Hew wrote: >>>>> >>>>> On Wed, Mar 9, 2011 at 1:14 PM, Rob Janes wrote: >>>>>> >>>>>> here's one that dequotes the key and value ... >>>>> >>>>> Thanks for the ideas, but.. >>>>> the issue isn't with extracting the keys and the values (and dequoting >>>>> them), >>>>> the task was only to strip trailing comments (while obeying quoted >>>>> strings) >>>>> >>>>> >>>>> >>>>> _______________________________________________ >>>>> toronto-pm mailing list >>>>> toronto-pm at pm.org >>>>> http://mail.pm.org/mailman/listinfo/toronto-pm >>>>> >>>>> >>>> _______________________________________________ >>>> toronto-pm mailing list >>>> toronto-pm at pm.org >>>> http://mail.pm.org/mailman/listinfo/toronto-pm >>> >>> _______________________________________________ >>> toronto-pm mailing list >>> toronto-pm at pm.org >>> http://mail.pm.org/mailman/listinfo/toronto-pm >>> >> _______________________________________________ >> toronto-pm mailing list >> toronto-pm at pm.org >> http://mail.pm.org/mailman/listinfo/toronto-pm >> > From legrady at gmail.com Wed Mar 9 11:37:57 2011 From: legrady at gmail.com (Tom Legrady) Date: Wed, 9 Mar 2011 14:37:57 -0500 Subject: [tpm] I wish I was better at regex's In-Reply-To: References: Message-ID: I would do it using a capturing split() on /([#"])/, which splits Before the string "Inside the string" # comment into [ 'Before the string', '"', 'Inside the string', '"', '#', 'comment', ] Before entering the array, you are obviously not in a string, not in a comment ... as you process elements, you find where you are. If you want to detect more 'separator characters', they're simple to add, and simple to handle depending on whether you are in a string, comment or other/ Tom -------------- next part -------------- An HTML attachment was scrubbed... URL: From janes.rob at gmail.com Wed Mar 9 11:38:05 2011 From: janes.rob at gmail.com (Rob Janes) Date: Wed, 9 Mar 2011 14:38:05 -0500 Subject: [tpm] I wish I was better at regex's In-Reply-To: References: Message-ID: this strips off the comment #!/usr/bin/env perl use strict; use warnings; while () { chomp; print "\n\n================\nline: $_\n"; if (m{ ^ ( (?:[^\\"';\s]| \\.| \s| "(?:[^"\\]|\\.)*"| '(?:[^'\\]|\\.)*' )+ ) (?:\s*;\s*(.*))? $ }x) { my ($words, $comment) = ($1, $2); $comment = "" unless defined($comment); print "matches!\n"; print "data is $words\ncomment is $comment\n"; } else { print "match FAILED!\n"; } } __DATA__ key="value" key=value key="value;" key="value1;value2" key="value1;value2" ; comment key='value1;value2' ; comment "key"="value1" "key"="value1" ; comment "key"="value1;value2" "key"="value1;value2" ; comment "key"="val\"ue1;value2" "key"="val\"ue1;value2" ; comment "key"='val\'ue1;value2' ; comment "key"='val\"ue1;value2' ; comment key="this=that" ; an = in the value key="value" ; a " in the comment this is a title ; and this is a comment On Wed, Mar 9, 2011 at 2:33 PM, Shaun Fryer wrote: > Indeed. Or "key=\'stuff\'"="value1=\'stuff\',value2=\'more ;stuff\'" ; > comment with " ' and ; > -- > Shaun Fryer > cell: 1-647-709-6509 > voip: 1-647-723-2729 > > > > > On Wed, Mar 9, 2011 at 2:30 PM, Rob Janes wrote: >> there's >> >> key="this=that" ?; an = in the value >> >> and >> >> key="value" ; a " in the comment >> >> On Wed, Mar 9, 2011 at 2:16 PM, Shaun Fryer wrote: >>> my $strip = qr{;[^\;]+$}; >>> while () { >>> ? ?chomp; >>> ? ?my ($key, $val) = split /=/; >>> ? ?my ($quote) = ($val =~ m{^(["'])}g); >>> ? ?if ($quote) { >>> ? ? ? ?($val) = ($val =~ m{^($quote[^\b]+($quote))}g); >>> ? ?} >>> ? ?else { >>> ? ? ? ?$val =~ s/$strip//; >>> ? ?} >>> ? ?print $key, '=', $val, "\n"; >>> } >>> >>> __DATA__ >>> key="value" >>> key=value >>> key="vlue;" >>> key="value1;value2" >>> key="value1;value2" ? ? ; comment >>> key='value1;value2' ? ? ; comment >>> "key"="value1" >>> "key"="value1" ? ? ? ? ?; comment >>> "key"="value1;value2" >>> "key"="value1;value2" ? ; comment >>> "key"="val\"ue1;value2" >>> "key"="val\"ue1;value2" ; comment >>> "key"='val\'ue1;value2' ; comment >>> "key"='val\"ue1;value2' ; comment >>> -- >>> Shaun Fryer >>> cell: 1-647-709-6509 >>> voip: 1-647-723-2729 >>> >>> >>> >>> >>> On Wed, Mar 9, 2011 at 2:12 PM, ? wrote: >>>> Doesn't work. ?Output: >>>> >>>> ---- >>>> key="value" >>>> key=value >>>> key="value1 >>>> key="value1;value2" >>>> key='value1;value2' >>>> "key"="value1" >>>> "key"="value1" >>>> "key"="value1 >>>> "key"="value1;value2" >>>> "key"="val\"ue1 >>>> "key"="val\"ue1;value2" >>>> "key"='val\'ue1;value2' >>>> "key"='val\"ue1;value2' >>>> ---- >>>> >>>> Look at line 3. >>>> >>>> Also it wouldn't catch a trailing semicolon with nothing after it. >>>> >>>> Here's a quick and dirty improvement, but it will still have problems: >>>> >>>> my $strip = qr{;[^\;\"\']*$}; >>>> while () { >>>> ? ?chomp; >>>> ? ?$_ =~ s/$strip//; >>>> ? ?print $_, "\n"; >>>> } >>>> >>>> >>>> Here's the way I would do it: >>>> >>>> ---- >>>> while () { >>>> ? ?chomp; >>>> >>>> ? ?my $stripped; >>>> ? ?my $quotechar = ""; >>>> ? ?foreach my $char (split(//, $_)) { >>>> ? ? ? ?if ($quotechar) { # We're currently quoted >>>> ? ? ? ? ? ?if ($char eq $quotechar) { # end of quote >>>> ? ? ? ? ? ? ? ?$quotechar = ""; >>>> ? ? ? ? ? ?} >>>> ? ? ? ?} else { # We're not currently quoted >>>> ? ? ? ? ? ?if ($char eq ';') { # The comment has begun! >>>> ? ? ? ? ? ? ? ?last(); >>>> ? ? ? ? ? ?} elsif ($char eq '"' || $char eq "'") { # start of quote >>>> ? ? ? ? ? ? ? ?$quotechar = $char; >>>> ? ? ? ? ? ?} >>>> ? ? ? ?} >>>> ? ? ? ?$stripped .= $char; >>>> ? ?} >>>> ? ?print "$stripped\n"; >>>> } >>>> >>>> __DATA__ >>>> key="value" >>>> key=value >>>> key="value1;value2" >>>> key="value1;value2" ? ? ; comment >>>> key='value1;value2' ? ? ; comment >>>> "key"="value1" >>>> "key"="value1" ? ? ? ? ?; comment >>>> "key"="value1;value2" >>>> "key"="value1;value2" ? ; comment >>>> "key"="val\"ue1;value2" >>>> "key"="val\"ue1;value2" ; comment >>>> "key"='val\'ue1;value2' ; comment >>>> "key"='val\"ue1;value2' ; comment >>>> ---- >>>> >>>> On Wed, 9 Mar 2011 13:48:39 -0500, Shaun Fryer wrote: >>>>> >>>>> my $strip = qr{;[^\;]+$}; >>>>> while () { >>>>> ? ?chomp; >>>>> ? ?$_ =~ s/$strip//; >>>>> ? ?print $_, "\n"; >>>>> } >>>>> >>>>> __DATA__ >>>>> key="value" >>>>> key=value >>>>> key="value1;value2" >>>>> key="value1;value2" ? ? ; comment >>>>> key='value1;value2' ? ? ; comment >>>>> "key"="value1" >>>>> "key"="value1" ? ? ? ? ?; comment >>>>> "key"="value1;value2" >>>>> "key"="value1;value2" ? ; comment >>>>> "key"="val\"ue1;value2" >>>>> "key"="val\"ue1;value2" ; comment >>>>> "key"='val\'ue1;value2' ; comment >>>>> "key"='val\"ue1;value2' ; comment >>>>> >>>>> -- >>>>> Shaun Fryer >>>>> cell: 1-647-709-6509 >>>>> voip: 1-647-723-2729 >>>>> >>>>> >>>>> >>>>> >>>>> On Wed, Mar 9, 2011 at 1:39 PM, Fulko Hew wrote: >>>>>> >>>>>> On Wed, Mar 9, 2011 at 1:14 PM, Rob Janes wrote: >>>>>>> >>>>>>> here's one that dequotes the key and value ... >>>>>> >>>>>> Thanks for the ideas, but.. >>>>>> the issue isn't with extracting the keys and the values (and dequoting >>>>>> them), >>>>>> the task was only to strip trailing comments (while obeying quoted >>>>>> strings) >>>>>> >>>>>> >>>>>> >>>>>> _______________________________________________ >>>>>> toronto-pm mailing list >>>>>> toronto-pm at pm.org >>>>>> http://mail.pm.org/mailman/listinfo/toronto-pm >>>>>> >>>>>> >>>>> _______________________________________________ >>>>> toronto-pm mailing list >>>>> toronto-pm at pm.org >>>>> http://mail.pm.org/mailman/listinfo/toronto-pm >>>> >>>> _______________________________________________ >>>> toronto-pm mailing list >>>> toronto-pm at pm.org >>>> http://mail.pm.org/mailman/listinfo/toronto-pm >>>> >>> _______________________________________________ >>> toronto-pm mailing list >>> toronto-pm at pm.org >>> http://mail.pm.org/mailman/listinfo/toronto-pm >>> >> > From sfryer at sourcery.ca Wed Mar 9 11:43:21 2011 From: sfryer at sourcery.ca (Shaun Fryer) Date: Wed, 9 Mar 2011 14:43:21 -0500 Subject: [tpm] I wish I was better at regex's In-Reply-To: References: Message-ID: nice (though pretty convoluted). the following breaks it. "key=\'stuff\'" = "value1=\'stuff\',value2=\'more ;stuff\'" ; comment with " ' and ; -- Shaun Fryer cell: 1-647-709-6509 voip: 1-647-723-2729 On Wed, Mar 9, 2011 at 2:38 PM, Rob Janes wrote: > this strips off the comment > > #!/usr/bin/env perl > > use strict; > use warnings; > > while () { > ?chomp; > > ?print "\n\n================\nline: $_\n"; > > ?if (m{ > ? ? ? ?^ > ? ? ? ?( > ? ? ? ? ?(?:[^\\"';\s]| > ? ? ? ? ? ?\\.| > ? ? ? ? ? ?\s| > ? ? ? ? ? ?"(?:[^"\\]|\\.)*"| > ? ? ? ? ? ?'(?:[^'\\]|\\.)*' > ? ? ? ? ?)+ > ? ? ? ?) > ? ? ? ?(?:\s*;\s*(.*))? > ? ? ? ?$ > ? ? ? ?}x) > ?{ > ? ?my ($words, $comment) = ($1, $2); > ? ?$comment = "" unless defined($comment); > ? ?print "matches!\n"; > > ? ?print "data is $words\ncomment is $comment\n"; > ?} > ?else > ?{ > ? ? print "match FAILED!\n"; > ?} > } > > __DATA__ > key="value" > key=value > key="value;" > key="value1;value2" > key="value1;value2" ? ? ; comment > key='value1;value2' ? ? ; comment > "key"="value1" > "key"="value1" ? ? ? ? ?; comment > "key"="value1;value2" > "key"="value1;value2" ? ; comment > "key"="val\"ue1;value2" > "key"="val\"ue1;value2" ; comment > "key"='val\'ue1;value2' ; comment > "key"='val\"ue1;value2' ; comment > key="this=that" ; an = in the value > key="value" ; a " in the comment > this is a title ? ; and this is a comment > > > On Wed, Mar 9, 2011 at 2:33 PM, Shaun Fryer wrote: >> Indeed. Or "key=\'stuff\'"="value1=\'stuff\',value2=\'more ;stuff\'" ; >> comment with " ' and ; >> -- >> Shaun Fryer >> cell: 1-647-709-6509 >> voip: 1-647-723-2729 >> >> >> >> >> On Wed, Mar 9, 2011 at 2:30 PM, Rob Janes wrote: >>> there's >>> >>> key="this=that" ?; an = in the value >>> >>> and >>> >>> key="value" ; a " in the comment >>> >>> On Wed, Mar 9, 2011 at 2:16 PM, Shaun Fryer wrote: >>>> my $strip = qr{;[^\;]+$}; >>>> while () { >>>> ? ?chomp; >>>> ? ?my ($key, $val) = split /=/; >>>> ? ?my ($quote) = ($val =~ m{^(["'])}g); >>>> ? ?if ($quote) { >>>> ? ? ? ?($val) = ($val =~ m{^($quote[^\b]+($quote))}g); >>>> ? ?} >>>> ? ?else { >>>> ? ? ? ?$val =~ s/$strip//; >>>> ? ?} >>>> ? ?print $key, '=', $val, "\n"; >>>> } >>>> >>>> __DATA__ >>>> key="value" >>>> key=value >>>> key="vlue;" >>>> key="value1;value2" >>>> key="value1;value2" ? ? ; comment >>>> key='value1;value2' ? ? ; comment >>>> "key"="value1" >>>> "key"="value1" ? ? ? ? ?; comment >>>> "key"="value1;value2" >>>> "key"="value1;value2" ? ; comment >>>> "key"="val\"ue1;value2" >>>> "key"="val\"ue1;value2" ; comment >>>> "key"='val\'ue1;value2' ; comment >>>> "key"='val\"ue1;value2' ; comment >>>> -- >>>> Shaun Fryer >>>> cell: 1-647-709-6509 >>>> voip: 1-647-723-2729 >>>> >>>> >>>> >>>> >>>> On Wed, Mar 9, 2011 at 2:12 PM, ? wrote: >>>>> Doesn't work. ?Output: >>>>> >>>>> ---- >>>>> key="value" >>>>> key=value >>>>> key="value1 >>>>> key="value1;value2" >>>>> key='value1;value2' >>>>> "key"="value1" >>>>> "key"="value1" >>>>> "key"="value1 >>>>> "key"="value1;value2" >>>>> "key"="val\"ue1 >>>>> "key"="val\"ue1;value2" >>>>> "key"='val\'ue1;value2' >>>>> "key"='val\"ue1;value2' >>>>> ---- >>>>> >>>>> Look at line 3. >>>>> >>>>> Also it wouldn't catch a trailing semicolon with nothing after it. >>>>> >>>>> Here's a quick and dirty improvement, but it will still have problems: >>>>> >>>>> my $strip = qr{;[^\;\"\']*$}; >>>>> while () { >>>>> ? ?chomp; >>>>> ? ?$_ =~ s/$strip//; >>>>> ? ?print $_, "\n"; >>>>> } >>>>> >>>>> >>>>> Here's the way I would do it: >>>>> >>>>> ---- >>>>> while () { >>>>> ? ?chomp; >>>>> >>>>> ? ?my $stripped; >>>>> ? ?my $quotechar = ""; >>>>> ? ?foreach my $char (split(//, $_)) { >>>>> ? ? ? ?if ($quotechar) { # We're currently quoted >>>>> ? ? ? ? ? ?if ($char eq $quotechar) { # end of quote >>>>> ? ? ? ? ? ? ? ?$quotechar = ""; >>>>> ? ? ? ? ? ?} >>>>> ? ? ? ?} else { # We're not currently quoted >>>>> ? ? ? ? ? ?if ($char eq ';') { # The comment has begun! >>>>> ? ? ? ? ? ? ? ?last(); >>>>> ? ? ? ? ? ?} elsif ($char eq '"' || $char eq "'") { # start of quote >>>>> ? ? ? ? ? ? ? ?$quotechar = $char; >>>>> ? ? ? ? ? ?} >>>>> ? ? ? ?} >>>>> ? ? ? ?$stripped .= $char; >>>>> ? ?} >>>>> ? ?print "$stripped\n"; >>>>> } >>>>> >>>>> __DATA__ >>>>> key="value" >>>>> key=value >>>>> key="value1;value2" >>>>> key="value1;value2" ? ? ; comment >>>>> key='value1;value2' ? ? ; comment >>>>> "key"="value1" >>>>> "key"="value1" ? ? ? ? ?; comment >>>>> "key"="value1;value2" >>>>> "key"="value1;value2" ? ; comment >>>>> "key"="val\"ue1;value2" >>>>> "key"="val\"ue1;value2" ; comment >>>>> "key"='val\'ue1;value2' ; comment >>>>> "key"='val\"ue1;value2' ; comment >>>>> ---- >>>>> >>>>> On Wed, 9 Mar 2011 13:48:39 -0500, Shaun Fryer wrote: >>>>>> >>>>>> my $strip = qr{;[^\;]+$}; >>>>>> while () { >>>>>> ? ?chomp; >>>>>> ? ?$_ =~ s/$strip//; >>>>>> ? ?print $_, "\n"; >>>>>> } >>>>>> >>>>>> __DATA__ >>>>>> key="value" >>>>>> key=value >>>>>> key="value1;value2" >>>>>> key="value1;value2" ? ? ; comment >>>>>> key='value1;value2' ? ? ; comment >>>>>> "key"="value1" >>>>>> "key"="value1" ? ? ? ? ?; comment >>>>>> "key"="value1;value2" >>>>>> "key"="value1;value2" ? ; comment >>>>>> "key"="val\"ue1;value2" >>>>>> "key"="val\"ue1;value2" ; comment >>>>>> "key"='val\'ue1;value2' ; comment >>>>>> "key"='val\"ue1;value2' ; comment >>>>>> >>>>>> -- >>>>>> Shaun Fryer >>>>>> cell: 1-647-709-6509 >>>>>> voip: 1-647-723-2729 >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> On Wed, Mar 9, 2011 at 1:39 PM, Fulko Hew wrote: >>>>>>> >>>>>>> On Wed, Mar 9, 2011 at 1:14 PM, Rob Janes wrote: >>>>>>>> >>>>>>>> here's one that dequotes the key and value ... >>>>>>> >>>>>>> Thanks for the ideas, but.. >>>>>>> the issue isn't with extracting the keys and the values (and dequoting >>>>>>> them), >>>>>>> the task was only to strip trailing comments (while obeying quoted >>>>>>> strings) >>>>>>> >>>>>>> >>>>>>> >>>>>>> _______________________________________________ >>>>>>> toronto-pm mailing list >>>>>>> toronto-pm at pm.org >>>>>>> http://mail.pm.org/mailman/listinfo/toronto-pm >>>>>>> >>>>>>> >>>>>> _______________________________________________ >>>>>> toronto-pm mailing list >>>>>> toronto-pm at pm.org >>>>>> http://mail.pm.org/mailman/listinfo/toronto-pm >>>>> >>>>> _______________________________________________ >>>>> toronto-pm mailing list >>>>> toronto-pm at pm.org >>>>> http://mail.pm.org/mailman/listinfo/toronto-pm >>>>> >>>> _______________________________________________ >>>> toronto-pm mailing list >>>> toronto-pm at pm.org >>>> http://mail.pm.org/mailman/listinfo/toronto-pm >>>> >>> >> > From janes.rob at gmail.com Wed Mar 9 11:46:53 2011 From: janes.rob at gmail.com (Rob Janes) Date: Wed, 9 Mar 2011 14:46:53 -0500 Subject: [tpm] I wish I was better at regex's In-Reply-To: References: Message-ID: ================ line: "key=\'stuff\'" = "value1=\'stuff\',value2=\'more ;stuff\'" ; comment matches! data is "key=\'stuff\'" = "value1=\'stuff\',value2=\'more ;stuff\'" comment is comment There's a key (in double quotes), an =, a value (in double quotes), and a comment. I don't understand. looks to me like it did pull off the comment properly. On Wed, Mar 9, 2011 at 2:43 PM, Shaun Fryer wrote: > nice (though pretty convoluted). the following breaks it. > > "key=\'stuff\'" = "value1=\'stuff\',value2=\'more ;stuff\'" ; comment > with " ' and ; > -- > Shaun Fryer > cell: 1-647-709-6509 > voip: 1-647-723-2729 > > > > > On Wed, Mar 9, 2011 at 2:38 PM, Rob Janes wrote: >> this strips off the comment >> >> #!/usr/bin/env perl >> >> use strict; >> use warnings; >> >> while () { >> ?chomp; >> >> ?print "\n\n================\nline: $_\n"; >> >> ?if (m{ >> ? ? ? ?^ >> ? ? ? ?( >> ? ? ? ? ?(?:[^\\"';\s]| >> ? ? ? ? ? ?\\.| >> ? ? ? ? ? ?\s| >> ? ? ? ? ? ?"(?:[^"\\]|\\.)*"| >> ? ? ? ? ? ?'(?:[^'\\]|\\.)*' >> ? ? ? ? ?)+ >> ? ? ? ?) >> ? ? ? ?(?:\s*;\s*(.*))? >> ? ? ? ?$ >> ? ? ? ?}x) >> ?{ >> ? ?my ($words, $comment) = ($1, $2); >> ? ?$comment = "" unless defined($comment); >> ? ?print "matches!\n"; >> >> ? ?print "data is $words\ncomment is $comment\n"; >> ?} >> ?else >> ?{ >> ? ? print "match FAILED!\n"; >> ?} >> } >> >> __DATA__ >> key="value" >> key=value >> key="value;" >> key="value1;value2" >> key="value1;value2" ? ? ; comment >> key='value1;value2' ? ? ; comment >> "key"="value1" >> "key"="value1" ? ? ? ? ?; comment >> "key"="value1;value2" >> "key"="value1;value2" ? ; comment >> "key"="val\"ue1;value2" >> "key"="val\"ue1;value2" ; comment >> "key"='val\'ue1;value2' ; comment >> "key"='val\"ue1;value2' ; comment >> key="this=that" ; an = in the value >> key="value" ; a " in the comment >> this is a title ? ; and this is a comment >> >> >> On Wed, Mar 9, 2011 at 2:33 PM, Shaun Fryer wrote: >>> Indeed. Or "key=\'stuff\'"="value1=\'stuff\',value2=\'more ;stuff\'" ; >>> comment with " ' and ; >>> -- >>> Shaun Fryer >>> cell: 1-647-709-6509 >>> voip: 1-647-723-2729 >>> >>> >>> >>> >>> On Wed, Mar 9, 2011 at 2:30 PM, Rob Janes wrote: >>>> there's >>>> >>>> key="this=that" ?; an = in the value >>>> >>>> and >>>> >>>> key="value" ; a " in the comment >>>> >>>> On Wed, Mar 9, 2011 at 2:16 PM, Shaun Fryer wrote: >>>>> my $strip = qr{;[^\;]+$}; >>>>> while () { >>>>> ? ?chomp; >>>>> ? ?my ($key, $val) = split /=/; >>>>> ? ?my ($quote) = ($val =~ m{^(["'])}g); >>>>> ? ?if ($quote) { >>>>> ? ? ? ?($val) = ($val =~ m{^($quote[^\b]+($quote))}g); >>>>> ? ?} >>>>> ? ?else { >>>>> ? ? ? ?$val =~ s/$strip//; >>>>> ? ?} >>>>> ? ?print $key, '=', $val, "\n"; >>>>> } >>>>> >>>>> __DATA__ >>>>> key="value" >>>>> key=value >>>>> key="vlue;" >>>>> key="value1;value2" >>>>> key="value1;value2" ? ? ; comment >>>>> key='value1;value2' ? ? ; comment >>>>> "key"="value1" >>>>> "key"="value1" ? ? ? ? ?; comment >>>>> "key"="value1;value2" >>>>> "key"="value1;value2" ? ; comment >>>>> "key"="val\"ue1;value2" >>>>> "key"="val\"ue1;value2" ; comment >>>>> "key"='val\'ue1;value2' ; comment >>>>> "key"='val\"ue1;value2' ; comment >>>>> -- >>>>> Shaun Fryer >>>>> cell: 1-647-709-6509 >>>>> voip: 1-647-723-2729 >>>>> >>>>> >>>>> >>>>> >>>>> On Wed, Mar 9, 2011 at 2:12 PM, ? wrote: >>>>>> Doesn't work. ?Output: >>>>>> >>>>>> ---- >>>>>> key="value" >>>>>> key=value >>>>>> key="value1 >>>>>> key="value1;value2" >>>>>> key='value1;value2' >>>>>> "key"="value1" >>>>>> "key"="value1" >>>>>> "key"="value1 >>>>>> "key"="value1;value2" >>>>>> "key"="val\"ue1 >>>>>> "key"="val\"ue1;value2" >>>>>> "key"='val\'ue1;value2' >>>>>> "key"='val\"ue1;value2' >>>>>> ---- >>>>>> >>>>>> Look at line 3. >>>>>> >>>>>> Also it wouldn't catch a trailing semicolon with nothing after it. >>>>>> >>>>>> Here's a quick and dirty improvement, but it will still have problems: >>>>>> >>>>>> my $strip = qr{;[^\;\"\']*$}; >>>>>> while () { >>>>>> ? ?chomp; >>>>>> ? ?$_ =~ s/$strip//; >>>>>> ? ?print $_, "\n"; >>>>>> } >>>>>> >>>>>> >>>>>> Here's the way I would do it: >>>>>> >>>>>> ---- >>>>>> while () { >>>>>> ? ?chomp; >>>>>> >>>>>> ? ?my $stripped; >>>>>> ? ?my $quotechar = ""; >>>>>> ? ?foreach my $char (split(//, $_)) { >>>>>> ? ? ? ?if ($quotechar) { # We're currently quoted >>>>>> ? ? ? ? ? ?if ($char eq $quotechar) { # end of quote >>>>>> ? ? ? ? ? ? ? ?$quotechar = ""; >>>>>> ? ? ? ? ? ?} >>>>>> ? ? ? ?} else { # We're not currently quoted >>>>>> ? ? ? ? ? ?if ($char eq ';') { # The comment has begun! >>>>>> ? ? ? ? ? ? ? ?last(); >>>>>> ? ? ? ? ? ?} elsif ($char eq '"' || $char eq "'") { # start of quote >>>>>> ? ? ? ? ? ? ? ?$quotechar = $char; >>>>>> ? ? ? ? ? ?} >>>>>> ? ? ? ?} >>>>>> ? ? ? ?$stripped .= $char; >>>>>> ? ?} >>>>>> ? ?print "$stripped\n"; >>>>>> } >>>>>> >>>>>> __DATA__ >>>>>> key="value" >>>>>> key=value >>>>>> key="value1;value2" >>>>>> key="value1;value2" ? ? ; comment >>>>>> key='value1;value2' ? ? ; comment >>>>>> "key"="value1" >>>>>> "key"="value1" ? ? ? ? ?; comment >>>>>> "key"="value1;value2" >>>>>> "key"="value1;value2" ? ; comment >>>>>> "key"="val\"ue1;value2" >>>>>> "key"="val\"ue1;value2" ; comment >>>>>> "key"='val\'ue1;value2' ; comment >>>>>> "key"='val\"ue1;value2' ; comment >>>>>> ---- >>>>>> >>>>>> On Wed, 9 Mar 2011 13:48:39 -0500, Shaun Fryer wrote: >>>>>>> >>>>>>> my $strip = qr{;[^\;]+$}; >>>>>>> while () { >>>>>>> ? ?chomp; >>>>>>> ? ?$_ =~ s/$strip//; >>>>>>> ? ?print $_, "\n"; >>>>>>> } >>>>>>> >>>>>>> __DATA__ >>>>>>> key="value" >>>>>>> key=value >>>>>>> key="value1;value2" >>>>>>> key="value1;value2" ? ? ; comment >>>>>>> key='value1;value2' ? ? ; comment >>>>>>> "key"="value1" >>>>>>> "key"="value1" ? ? ? ? ?; comment >>>>>>> "key"="value1;value2" >>>>>>> "key"="value1;value2" ? ; comment >>>>>>> "key"="val\"ue1;value2" >>>>>>> "key"="val\"ue1;value2" ; comment >>>>>>> "key"='val\'ue1;value2' ; comment >>>>>>> "key"='val\"ue1;value2' ; comment >>>>>>> >>>>>>> -- >>>>>>> Shaun Fryer >>>>>>> cell: 1-647-709-6509 >>>>>>> voip: 1-647-723-2729 >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> On Wed, Mar 9, 2011 at 1:39 PM, Fulko Hew wrote: >>>>>>>> >>>>>>>> On Wed, Mar 9, 2011 at 1:14 PM, Rob Janes wrote: >>>>>>>>> >>>>>>>>> here's one that dequotes the key and value ... >>>>>>>> >>>>>>>> Thanks for the ideas, but.. >>>>>>>> the issue isn't with extracting the keys and the values (and dequoting >>>>>>>> them), >>>>>>>> the task was only to strip trailing comments (while obeying quoted >>>>>>>> strings) >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> _______________________________________________ >>>>>>>> toronto-pm mailing list >>>>>>>> toronto-pm at pm.org >>>>>>>> http://mail.pm.org/mailman/listinfo/toronto-pm >>>>>>>> >>>>>>>> >>>>>>> _______________________________________________ >>>>>>> toronto-pm mailing list >>>>>>> toronto-pm at pm.org >>>>>>> http://mail.pm.org/mailman/listinfo/toronto-pm >>>>>> >>>>>> _______________________________________________ >>>>>> toronto-pm mailing list >>>>>> toronto-pm at pm.org >>>>>> http://mail.pm.org/mailman/listinfo/toronto-pm >>>>>> >>>>> _______________________________________________ >>>>> toronto-pm mailing list >>>>> toronto-pm at pm.org >>>>> http://mail.pm.org/mailman/listinfo/toronto-pm >>>>> >>>> >>> >> > From sfryer at sourcery.ca Wed Mar 9 11:46:42 2011 From: sfryer at sourcery.ca (Shaun Fryer) Date: Wed, 9 Mar 2011 14:46:42 -0500 Subject: [tpm] I wish I was better at regex's In-Reply-To: References: Message-ID: or take the managerial approach and just tell people not to do weird things in their keys/values/comments. there's only so much heuristics which can reasonably/practically be applied to such a relatively simple problem. it's far less effort to strike the human element first and foremost. -- Shaun Fryer cell: 1-647-709-6509 voip: 1-647-723-2729 On Wed, Mar 9, 2011 at 2:42 PM, Richard Dice wrote: > Those are getting closer, but honestly this can go way beyond the realm of what regexps can provide. ?For example, the text in the comment area... In theory, it could contain text like > > ?"key"="Val\"ue" ; tricked you!! > > To fully, correctly solve this you need a full parser. ?Like Parse::RecDescent > > Which is like hitting a melon with an atomic bomb. > > If you have ANY foreknowledge of the sorts of files you are going to receive and the kind of comments they will (NOT "might, theoretically") contain, just cook up some cheap-ass line mangling logic, maybe using some regexps, maybe some substr and index and rindex. > > Sent from my iPhone > > On 2011-03-09, at 2:32 PM, Fulko Hew wrote: > >> On Wed, Mar 9, 2011 at 2:29 PM, Shaun Fryer wrote: >>> >>> It's very difficult to do without matching quotes, and hence key/value >>> pairs. For instance, what if the comment contains a quote, just as the >>> quotes may contain a semi-colon? In this case I've sidestepped the >>> problem of escaped quotes by using a word-boundary (\b) match inside >>> any matched quotes. the side effect of this, is that any spaces inside >>> the quotes will count... >>> >>> good luck if you can do it without matching keys/values/quotes. I've >>> already got beers riding on the solution. ;) >> >> Thats why I then looked at things like: >> >> Regexp::Common::balanced >> Regexp::Common::comment >> >> but I couldn't figure out how to apply them. >> _______________________________________________ >> toronto-pm mailing list >> toronto-pm at pm.org >> http://mail.pm.org/mailman/listinfo/toronto-pm > From sfryer at sourcery.ca Wed Mar 9 11:48:30 2011 From: sfryer at sourcery.ca (Shaun Fryer) Date: Wed, 9 Mar 2011 14:48:30 -0500 Subject: [tpm] I wish I was better at regex's In-Reply-To: References: Message-ID: funny. I got... line: key=\'stuff\'" = "value1=\'stuff\',value2=\'more ;stuff\'" ; comment with = " ' and ; matches! data is key=\'stuff\'" = "value1=\'stuff\',value2=\'more comment is stuff\'" ; comment with = " ' and ; as you can see, the (stuff\'";) got put in the comment. -- Shaun Fryer cell: 1-647-709-6509 voip: 1-647-723-2729 On Wed, Mar 9, 2011 at 2:46 PM, Rob Janes wrote: > ================ > line: "key=\'stuff\'" = "value1=\'stuff\',value2=\'more ;stuff\'" ; comment > matches! > data is "key=\'stuff\'" = "value1=\'stuff\',value2=\'more ;stuff\'" > comment is comment > > There's a key (in double quotes), an =, a value (in double quotes), > and a comment. > > I don't understand. ?looks to me like it did pull off the comment properly. > > On Wed, Mar 9, 2011 at 2:43 PM, Shaun Fryer wrote: >> nice (though pretty convoluted). the following breaks it. >> >> "key=\'stuff\'" = "value1=\'stuff\',value2=\'more ;stuff\'" ; comment >> with " ' and ; >> -- >> Shaun Fryer >> cell: 1-647-709-6509 >> voip: 1-647-723-2729 >> >> >> >> >> On Wed, Mar 9, 2011 at 2:38 PM, Rob Janes wrote: >>> this strips off the comment >>> >>> #!/usr/bin/env perl >>> >>> use strict; >>> use warnings; >>> >>> while () { >>> ?chomp; >>> >>> ?print "\n\n================\nline: $_\n"; >>> >>> ?if (m{ >>> ? ? ? ?^ >>> ? ? ? ?( >>> ? ? ? ? ?(?:[^\\"';\s]| >>> ? ? ? ? ? ?\\.| >>> ? ? ? ? ? ?\s| >>> ? ? ? ? ? ?"(?:[^"\\]|\\.)*"| >>> ? ? ? ? ? ?'(?:[^'\\]|\\.)*' >>> ? ? ? ? ?)+ >>> ? ? ? ?) >>> ? ? ? ?(?:\s*;\s*(.*))? >>> ? ? ? ?$ >>> ? ? ? ?}x) >>> ?{ >>> ? ?my ($words, $comment) = ($1, $2); >>> ? ?$comment = "" unless defined($comment); >>> ? ?print "matches!\n"; >>> >>> ? ?print "data is $words\ncomment is $comment\n"; >>> ?} >>> ?else >>> ?{ >>> ? ? print "match FAILED!\n"; >>> ?} >>> } >>> >>> __DATA__ >>> key="value" >>> key=value >>> key="value;" >>> key="value1;value2" >>> key="value1;value2" ? ? ; comment >>> key='value1;value2' ? ? ; comment >>> "key"="value1" >>> "key"="value1" ? ? ? ? ?; comment >>> "key"="value1;value2" >>> "key"="value1;value2" ? ; comment >>> "key"="val\"ue1;value2" >>> "key"="val\"ue1;value2" ; comment >>> "key"='val\'ue1;value2' ; comment >>> "key"='val\"ue1;value2' ; comment >>> key="this=that" ; an = in the value >>> key="value" ; a " in the comment >>> this is a title ? ; and this is a comment >>> >>> >>> On Wed, Mar 9, 2011 at 2:33 PM, Shaun Fryer wrote: >>>> Indeed. Or "key=\'stuff\'"="value1=\'stuff\',value2=\'more ;stuff\'" ; >>>> comment with " ' and ; >>>> -- >>>> Shaun Fryer >>>> cell: 1-647-709-6509 >>>> voip: 1-647-723-2729 >>>> >>>> >>>> >>>> >>>> On Wed, Mar 9, 2011 at 2:30 PM, Rob Janes wrote: >>>>> there's >>>>> >>>>> key="this=that" ?; an = in the value >>>>> >>>>> and >>>>> >>>>> key="value" ; a " in the comment >>>>> >>>>> On Wed, Mar 9, 2011 at 2:16 PM, Shaun Fryer wrote: >>>>>> my $strip = qr{;[^\;]+$}; >>>>>> while () { >>>>>> ? ?chomp; >>>>>> ? ?my ($key, $val) = split /=/; >>>>>> ? ?my ($quote) = ($val =~ m{^(["'])}g); >>>>>> ? ?if ($quote) { >>>>>> ? ? ? ?($val) = ($val =~ m{^($quote[^\b]+($quote))}g); >>>>>> ? ?} >>>>>> ? ?else { >>>>>> ? ? ? ?$val =~ s/$strip//; >>>>>> ? ?} >>>>>> ? ?print $key, '=', $val, "\n"; >>>>>> } >>>>>> >>>>>> __DATA__ >>>>>> key="value" >>>>>> key=value >>>>>> key="vlue;" >>>>>> key="value1;value2" >>>>>> key="value1;value2" ? ? ; comment >>>>>> key='value1;value2' ? ? ; comment >>>>>> "key"="value1" >>>>>> "key"="value1" ? ? ? ? ?; comment >>>>>> "key"="value1;value2" >>>>>> "key"="value1;value2" ? ; comment >>>>>> "key"="val\"ue1;value2" >>>>>> "key"="val\"ue1;value2" ; comment >>>>>> "key"='val\'ue1;value2' ; comment >>>>>> "key"='val\"ue1;value2' ; comment >>>>>> -- >>>>>> Shaun Fryer >>>>>> cell: 1-647-709-6509 >>>>>> voip: 1-647-723-2729 >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> On Wed, Mar 9, 2011 at 2:12 PM, ? wrote: >>>>>>> Doesn't work. ?Output: >>>>>>> >>>>>>> ---- >>>>>>> key="value" >>>>>>> key=value >>>>>>> key="value1 >>>>>>> key="value1;value2" >>>>>>> key='value1;value2' >>>>>>> "key"="value1" >>>>>>> "key"="value1" >>>>>>> "key"="value1 >>>>>>> "key"="value1;value2" >>>>>>> "key"="val\"ue1 >>>>>>> "key"="val\"ue1;value2" >>>>>>> "key"='val\'ue1;value2' >>>>>>> "key"='val\"ue1;value2' >>>>>>> ---- >>>>>>> >>>>>>> Look at line 3. >>>>>>> >>>>>>> Also it wouldn't catch a trailing semicolon with nothing after it. >>>>>>> >>>>>>> Here's a quick and dirty improvement, but it will still have problems: >>>>>>> >>>>>>> my $strip = qr{;[^\;\"\']*$}; >>>>>>> while () { >>>>>>> ? ?chomp; >>>>>>> ? ?$_ =~ s/$strip//; >>>>>>> ? ?print $_, "\n"; >>>>>>> } >>>>>>> >>>>>>> >>>>>>> Here's the way I would do it: >>>>>>> >>>>>>> ---- >>>>>>> while () { >>>>>>> ? ?chomp; >>>>>>> >>>>>>> ? ?my $stripped; >>>>>>> ? ?my $quotechar = ""; >>>>>>> ? ?foreach my $char (split(//, $_)) { >>>>>>> ? ? ? ?if ($quotechar) { # We're currently quoted >>>>>>> ? ? ? ? ? ?if ($char eq $quotechar) { # end of quote >>>>>>> ? ? ? ? ? ? ? ?$quotechar = ""; >>>>>>> ? ? ? ? ? ?} >>>>>>> ? ? ? ?} else { # We're not currently quoted >>>>>>> ? ? ? ? ? ?if ($char eq ';') { # The comment has begun! >>>>>>> ? ? ? ? ? ? ? ?last(); >>>>>>> ? ? ? ? ? ?} elsif ($char eq '"' || $char eq "'") { # start of quote >>>>>>> ? ? ? ? ? ? ? ?$quotechar = $char; >>>>>>> ? ? ? ? ? ?} >>>>>>> ? ? ? ?} >>>>>>> ? ? ? ?$stripped .= $char; >>>>>>> ? ?} >>>>>>> ? ?print "$stripped\n"; >>>>>>> } >>>>>>> >>>>>>> __DATA__ >>>>>>> key="value" >>>>>>> key=value >>>>>>> key="value1;value2" >>>>>>> key="value1;value2" ? ? ; comment >>>>>>> key='value1;value2' ? ? ; comment >>>>>>> "key"="value1" >>>>>>> "key"="value1" ? ? ? ? ?; comment >>>>>>> "key"="value1;value2" >>>>>>> "key"="value1;value2" ? ; comment >>>>>>> "key"="val\"ue1;value2" >>>>>>> "key"="val\"ue1;value2" ; comment >>>>>>> "key"='val\'ue1;value2' ; comment >>>>>>> "key"='val\"ue1;value2' ; comment >>>>>>> ---- >>>>>>> >>>>>>> On Wed, 9 Mar 2011 13:48:39 -0500, Shaun Fryer wrote: >>>>>>>> >>>>>>>> my $strip = qr{;[^\;]+$}; >>>>>>>> while () { >>>>>>>> ? ?chomp; >>>>>>>> ? ?$_ =~ s/$strip//; >>>>>>>> ? ?print $_, "\n"; >>>>>>>> } >>>>>>>> >>>>>>>> __DATA__ >>>>>>>> key="value" >>>>>>>> key=value >>>>>>>> key="value1;value2" >>>>>>>> key="value1;value2" ? ? ; comment >>>>>>>> key='value1;value2' ? ? ; comment >>>>>>>> "key"="value1" >>>>>>>> "key"="value1" ? ? ? ? ?; comment >>>>>>>> "key"="value1;value2" >>>>>>>> "key"="value1;value2" ? ; comment >>>>>>>> "key"="val\"ue1;value2" >>>>>>>> "key"="val\"ue1;value2" ; comment >>>>>>>> "key"='val\'ue1;value2' ; comment >>>>>>>> "key"='val\"ue1;value2' ; comment >>>>>>>> >>>>>>>> -- >>>>>>>> Shaun Fryer >>>>>>>> cell: 1-647-709-6509 >>>>>>>> voip: 1-647-723-2729 >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> On Wed, Mar 9, 2011 at 1:39 PM, Fulko Hew wrote: >>>>>>>>> >>>>>>>>> On Wed, Mar 9, 2011 at 1:14 PM, Rob Janes wrote: >>>>>>>>>> >>>>>>>>>> here's one that dequotes the key and value ... >>>>>>>>> >>>>>>>>> Thanks for the ideas, but.. >>>>>>>>> the issue isn't with extracting the keys and the values (and dequoting >>>>>>>>> them), >>>>>>>>> the task was only to strip trailing comments (while obeying quoted >>>>>>>>> strings) >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> _______________________________________________ >>>>>>>>> toronto-pm mailing list >>>>>>>>> toronto-pm at pm.org >>>>>>>>> http://mail.pm.org/mailman/listinfo/toronto-pm >>>>>>>>> >>>>>>>>> >>>>>>>> _______________________________________________ >>>>>>>> toronto-pm mailing list >>>>>>>> toronto-pm at pm.org >>>>>>>> http://mail.pm.org/mailman/listinfo/toronto-pm >>>>>>> >>>>>>> _______________________________________________ >>>>>>> toronto-pm mailing list >>>>>>> toronto-pm at pm.org >>>>>>> http://mail.pm.org/mailman/listinfo/toronto-pm >>>>>>> >>>>>> _______________________________________________ >>>>>> toronto-pm mailing list >>>>>> toronto-pm at pm.org >>>>>> http://mail.pm.org/mailman/listinfo/toronto-pm >>>>>> >>>>> >>>> >>> >> > From fulko.hew at gmail.com Wed Mar 9 11:48:44 2011 From: fulko.hew at gmail.com (Fulko Hew) Date: Wed, 9 Mar 2011 14:48:44 -0500 Subject: [tpm] I wish I was better at regex's In-Reply-To: References: Message-ID: On Wed, Mar 9, 2011 at 2:46 PM, Rob Janes wrote: > ================ > line: "key=\'stuff\'" = "value1=\'stuff\',value2=\'more ;stuff\'" ; comment > matches! > data is "key=\'stuff\'" = "value1=\'stuff\',value2=\'more ;stuff\'" > comment is comment > > There's a key (in double quotes), an =, a value (in double quotes), > and a comment. > > I don't understand. looks to me like it did pull off the comment properly. I think you pulled it off ! From janes.rob at gmail.com Wed Mar 9 11:53:10 2011 From: janes.rob at gmail.com (Rob Janes) Date: Wed, 9 Mar 2011 14:53:10 -0500 Subject: [tpm] I wish I was better at regex's In-Reply-To: References: Message-ID: you're missing a double quote before key. ================ line: key=\'stuff\'" = "value1=\'stuff\',value2=\'more ;stuff\'" ; comment with = " ' and ; matches! data is key=\'stuff\'" = "value1=\'stuff\',value2=\'more comment is stuff\'" ; comment with = " ' and ; ================ line: "key=\'stuff\'" = "value1=\'stuff\',value2=\'more ;stuff\'" ; comment with = " ' and ; matches! data is "key=\'stuff\'" = "value1=\'stuff\',value2=\'more ;stuff\'" comment is comment with = " ' and ; On Wed, Mar 9, 2011 at 2:48 PM, Shaun Fryer wrote: > funny. I got... > > line: key=\'stuff\'" = "value1=\'stuff\',value2=\'more ;stuff\'" ; > comment with = " ' and ; > matches! > data is key=\'stuff\'" = "value1=\'stuff\',value2=\'more > comment is stuff\'" ; comment with = " ' and ; > > as you can see, the (stuff\'";) got put in the comment. > -- > Shaun Fryer > cell: 1-647-709-6509 > voip: 1-647-723-2729 > > > > > On Wed, Mar 9, 2011 at 2:46 PM, Rob Janes wrote: >> ================ >> line: "key=\'stuff\'" = "value1=\'stuff\',value2=\'more ;stuff\'" ; comment >> matches! >> data is "key=\'stuff\'" = "value1=\'stuff\',value2=\'more ;stuff\'" >> comment is comment >> >> There's a key (in double quotes), an =, a value (in double quotes), >> and a comment. >> >> I don't understand. ?looks to me like it did pull off the comment properly. >> >> On Wed, Mar 9, 2011 at 2:43 PM, Shaun Fryer wrote: >>> nice (though pretty convoluted). the following breaks it. >>> >>> "key=\'stuff\'" = "value1=\'stuff\',value2=\'more ;stuff\'" ; comment >>> with " ' and ; >>> -- >>> Shaun Fryer >>> cell: 1-647-709-6509 >>> voip: 1-647-723-2729 >>> >>> >>> >>> >>> On Wed, Mar 9, 2011 at 2:38 PM, Rob Janes wrote: >>>> this strips off the comment >>>> >>>> #!/usr/bin/env perl >>>> >>>> use strict; >>>> use warnings; >>>> >>>> while () { >>>> ?chomp; >>>> >>>> ?print "\n\n================\nline: $_\n"; >>>> >>>> ?if (m{ >>>> ? ? ? ?^ >>>> ? ? ? ?( >>>> ? ? ? ? ?(?:[^\\"';\s]| >>>> ? ? ? ? ? ?\\.| >>>> ? ? ? ? ? ?\s| >>>> ? ? ? ? ? ?"(?:[^"\\]|\\.)*"| >>>> ? ? ? ? ? ?'(?:[^'\\]|\\.)*' >>>> ? ? ? ? ?)+ >>>> ? ? ? ?) >>>> ? ? ? ?(?:\s*;\s*(.*))? >>>> ? ? ? ?$ >>>> ? ? ? ?}x) >>>> ?{ >>>> ? ?my ($words, $comment) = ($1, $2); >>>> ? ?$comment = "" unless defined($comment); >>>> ? ?print "matches!\n"; >>>> >>>> ? ?print "data is $words\ncomment is $comment\n"; >>>> ?} >>>> ?else >>>> ?{ >>>> ? ? print "match FAILED!\n"; >>>> ?} >>>> } >>>> >>>> __DATA__ >>>> key="value" >>>> key=value >>>> key="value;" >>>> key="value1;value2" >>>> key="value1;value2" ? ? ; comment >>>> key='value1;value2' ? ? ; comment >>>> "key"="value1" >>>> "key"="value1" ? ? ? ? ?; comment >>>> "key"="value1;value2" >>>> "key"="value1;value2" ? ; comment >>>> "key"="val\"ue1;value2" >>>> "key"="val\"ue1;value2" ; comment >>>> "key"='val\'ue1;value2' ; comment >>>> "key"='val\"ue1;value2' ; comment >>>> key="this=that" ; an = in the value >>>> key="value" ; a " in the comment >>>> this is a title ? ; and this is a comment >>>> >>>> >>>> On Wed, Mar 9, 2011 at 2:33 PM, Shaun Fryer wrote: >>>>> Indeed. Or "key=\'stuff\'"="value1=\'stuff\',value2=\'more ;stuff\'" ; >>>>> comment with " ' and ; >>>>> -- >>>>> Shaun Fryer >>>>> cell: 1-647-709-6509 >>>>> voip: 1-647-723-2729 >>>>> >>>>> >>>>> >>>>> >>>>> On Wed, Mar 9, 2011 at 2:30 PM, Rob Janes wrote: >>>>>> there's >>>>>> >>>>>> key="this=that" ?; an = in the value >>>>>> >>>>>> and >>>>>> >>>>>> key="value" ; a " in the comment >>>>>> >>>>>> On Wed, Mar 9, 2011 at 2:16 PM, Shaun Fryer wrote: >>>>>>> my $strip = qr{;[^\;]+$}; >>>>>>> while () { >>>>>>> ? ?chomp; >>>>>>> ? ?my ($key, $val) = split /=/; >>>>>>> ? ?my ($quote) = ($val =~ m{^(["'])}g); >>>>>>> ? ?if ($quote) { >>>>>>> ? ? ? ?($val) = ($val =~ m{^($quote[^\b]+($quote))}g); >>>>>>> ? ?} >>>>>>> ? ?else { >>>>>>> ? ? ? ?$val =~ s/$strip//; >>>>>>> ? ?} >>>>>>> ? ?print $key, '=', $val, "\n"; >>>>>>> } >>>>>>> >>>>>>> __DATA__ >>>>>>> key="value" >>>>>>> key=value >>>>>>> key="vlue;" >>>>>>> key="value1;value2" >>>>>>> key="value1;value2" ? ? ; comment >>>>>>> key='value1;value2' ? ? ; comment >>>>>>> "key"="value1" >>>>>>> "key"="value1" ? ? ? ? ?; comment >>>>>>> "key"="value1;value2" >>>>>>> "key"="value1;value2" ? ; comment >>>>>>> "key"="val\"ue1;value2" >>>>>>> "key"="val\"ue1;value2" ; comment >>>>>>> "key"='val\'ue1;value2' ; comment >>>>>>> "key"='val\"ue1;value2' ; comment >>>>>>> -- >>>>>>> Shaun Fryer >>>>>>> cell: 1-647-709-6509 >>>>>>> voip: 1-647-723-2729 >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> On Wed, Mar 9, 2011 at 2:12 PM, ? wrote: >>>>>>>> Doesn't work. ?Output: >>>>>>>> >>>>>>>> ---- >>>>>>>> key="value" >>>>>>>> key=value >>>>>>>> key="value1 >>>>>>>> key="value1;value2" >>>>>>>> key='value1;value2' >>>>>>>> "key"="value1" >>>>>>>> "key"="value1" >>>>>>>> "key"="value1 >>>>>>>> "key"="value1;value2" >>>>>>>> "key"="val\"ue1 >>>>>>>> "key"="val\"ue1;value2" >>>>>>>> "key"='val\'ue1;value2' >>>>>>>> "key"='val\"ue1;value2' >>>>>>>> ---- >>>>>>>> >>>>>>>> Look at line 3. >>>>>>>> >>>>>>>> Also it wouldn't catch a trailing semicolon with nothing after it. >>>>>>>> >>>>>>>> Here's a quick and dirty improvement, but it will still have problems: >>>>>>>> >>>>>>>> my $strip = qr{;[^\;\"\']*$}; >>>>>>>> while () { >>>>>>>> ? ?chomp; >>>>>>>> ? ?$_ =~ s/$strip//; >>>>>>>> ? ?print $_, "\n"; >>>>>>>> } >>>>>>>> >>>>>>>> >>>>>>>> Here's the way I would do it: >>>>>>>> >>>>>>>> ---- >>>>>>>> while () { >>>>>>>> ? ?chomp; >>>>>>>> >>>>>>>> ? ?my $stripped; >>>>>>>> ? ?my $quotechar = ""; >>>>>>>> ? ?foreach my $char (split(//, $_)) { >>>>>>>> ? ? ? ?if ($quotechar) { # We're currently quoted >>>>>>>> ? ? ? ? ? ?if ($char eq $quotechar) { # end of quote >>>>>>>> ? ? ? ? ? ? ? ?$quotechar = ""; >>>>>>>> ? ? ? ? ? ?} >>>>>>>> ? ? ? ?} else { # We're not currently quoted >>>>>>>> ? ? ? ? ? ?if ($char eq ';') { # The comment has begun! >>>>>>>> ? ? ? ? ? ? ? ?last(); >>>>>>>> ? ? ? ? ? ?} elsif ($char eq '"' || $char eq "'") { # start of quote >>>>>>>> ? ? ? ? ? ? ? ?$quotechar = $char; >>>>>>>> ? ? ? ? ? ?} >>>>>>>> ? ? ? ?} >>>>>>>> ? ? ? ?$stripped .= $char; >>>>>>>> ? ?} >>>>>>>> ? ?print "$stripped\n"; >>>>>>>> } >>>>>>>> >>>>>>>> __DATA__ >>>>>>>> key="value" >>>>>>>> key=value >>>>>>>> key="value1;value2" >>>>>>>> key="value1;value2" ? ? ; comment >>>>>>>> key='value1;value2' ? ? ; comment >>>>>>>> "key"="value1" >>>>>>>> "key"="value1" ? ? ? ? ?; comment >>>>>>>> "key"="value1;value2" >>>>>>>> "key"="value1;value2" ? ; comment >>>>>>>> "key"="val\"ue1;value2" >>>>>>>> "key"="val\"ue1;value2" ; comment >>>>>>>> "key"='val\'ue1;value2' ; comment >>>>>>>> "key"='val\"ue1;value2' ; comment >>>>>>>> ---- >>>>>>>> >>>>>>>> On Wed, 9 Mar 2011 13:48:39 -0500, Shaun Fryer wrote: >>>>>>>>> >>>>>>>>> my $strip = qr{;[^\;]+$}; >>>>>>>>> while () { >>>>>>>>> ? ?chomp; >>>>>>>>> ? ?$_ =~ s/$strip//; >>>>>>>>> ? ?print $_, "\n"; >>>>>>>>> } >>>>>>>>> >>>>>>>>> __DATA__ >>>>>>>>> key="value" >>>>>>>>> key=value >>>>>>>>> key="value1;value2" >>>>>>>>> key="value1;value2" ? ? ; comment >>>>>>>>> key='value1;value2' ? ? ; comment >>>>>>>>> "key"="value1" >>>>>>>>> "key"="value1" ? ? ? ? ?; comment >>>>>>>>> "key"="value1;value2" >>>>>>>>> "key"="value1;value2" ? ; comment >>>>>>>>> "key"="val\"ue1;value2" >>>>>>>>> "key"="val\"ue1;value2" ; comment >>>>>>>>> "key"='val\'ue1;value2' ; comment >>>>>>>>> "key"='val\"ue1;value2' ; comment >>>>>>>>> >>>>>>>>> -- >>>>>>>>> Shaun Fryer >>>>>>>>> cell: 1-647-709-6509 >>>>>>>>> voip: 1-647-723-2729 >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> On Wed, Mar 9, 2011 at 1:39 PM, Fulko Hew wrote: >>>>>>>>>> >>>>>>>>>> On Wed, Mar 9, 2011 at 1:14 PM, Rob Janes wrote: >>>>>>>>>>> >>>>>>>>>>> here's one that dequotes the key and value ... >>>>>>>>>> >>>>>>>>>> Thanks for the ideas, but.. >>>>>>>>>> the issue isn't with extracting the keys and the values (and dequoting >>>>>>>>>> them), >>>>>>>>>> the task was only to strip trailing comments (while obeying quoted >>>>>>>>>> strings) >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> _______________________________________________ >>>>>>>>>> toronto-pm mailing list >>>>>>>>>> toronto-pm at pm.org >>>>>>>>>> http://mail.pm.org/mailman/listinfo/toronto-pm >>>>>>>>>> >>>>>>>>>> >>>>>>>>> _______________________________________________ >>>>>>>>> toronto-pm mailing list >>>>>>>>> toronto-pm at pm.org >>>>>>>>> http://mail.pm.org/mailman/listinfo/toronto-pm >>>>>>>> >>>>>>>> _______________________________________________ >>>>>>>> toronto-pm mailing list >>>>>>>> toronto-pm at pm.org >>>>>>>> http://mail.pm.org/mailman/listinfo/toronto-pm >>>>>>>> >>>>>>> _______________________________________________ >>>>>>> toronto-pm mailing list >>>>>>> toronto-pm at pm.org >>>>>>> http://mail.pm.org/mailman/listinfo/toronto-pm >>>>>>> >>>>>> >>>>> >>>> >>> >> > From janes.rob at gmail.com Wed Mar 9 11:54:26 2011 From: janes.rob at gmail.com (Rob Janes) Date: Wed, 9 Mar 2011 14:54:26 -0500 Subject: [tpm] I wish I was better at regex's In-Reply-To: References: Message-ID: i code for beer. :-) On Wed, Mar 9, 2011 at 2:48 PM, Fulko Hew wrote: > On Wed, Mar 9, 2011 at 2:46 PM, Rob Janes wrote: >> ================ >> line: "key=\'stuff\'" = "value1=\'stuff\',value2=\'more ;stuff\'" ; comment >> matches! >> data is "key=\'stuff\'" = "value1=\'stuff\',value2=\'more ;stuff\'" >> comment is comment >> >> There's a key (in double quotes), an =, a value (in double quotes), >> and a comment. >> >> I don't understand. ?looks to me like it did pull off the comment properly. > > > I think you pulled it off ! > From sfryer at sourcery.ca Wed Mar 9 11:55:01 2011 From: sfryer at sourcery.ca (Shaun Fryer) Date: Wed, 9 Mar 2011 14:55:01 -0500 Subject: [tpm] I wish I was better at regex's In-Reply-To: References: Message-ID: Ah. My bad! You win! -- Shaun Fryer cell: 1-647-709-6509 voip: 1-647-723-2729 On Wed, Mar 9, 2011 at 2:53 PM, Rob Janes wrote: > you're missing a double quote before key. > > ================ > line: key=\'stuff\'" = "value1=\'stuff\',value2=\'more ;stuff\'" ; > comment with = " ' and ; > matches! > data is key=\'stuff\'" = "value1=\'stuff\',value2=\'more > comment is stuff\'" ; comment with = " ' and ; > > > ================ > line: "key=\'stuff\'" = "value1=\'stuff\',value2=\'more ;stuff\'" ; > comment with = " ' and ; > matches! > data is "key=\'stuff\'" = "value1=\'stuff\',value2=\'more ;stuff\'" > comment is comment with = " ' and ; > > > On Wed, Mar 9, 2011 at 2:48 PM, Shaun Fryer wrote: >> funny. I got... >> >> line: key=\'stuff\'" = "value1=\'stuff\',value2=\'more ;stuff\'" ; >> comment with = " ' and ; >> matches! >> data is key=\'stuff\'" = "value1=\'stuff\',value2=\'more >> comment is stuff\'" ; comment with = " ' and ; >> >> as you can see, the (stuff\'";) got put in the comment. >> -- >> Shaun Fryer >> cell: 1-647-709-6509 >> voip: 1-647-723-2729 >> >> >> >> >> On Wed, Mar 9, 2011 at 2:46 PM, Rob Janes wrote: >>> ================ >>> line: "key=\'stuff\'" = "value1=\'stuff\',value2=\'more ;stuff\'" ; comment >>> matches! >>> data is "key=\'stuff\'" = "value1=\'stuff\',value2=\'more ;stuff\'" >>> comment is comment >>> >>> There's a key (in double quotes), an =, a value (in double quotes), >>> and a comment. >>> >>> I don't understand. ?looks to me like it did pull off the comment properly. >>> >>> On Wed, Mar 9, 2011 at 2:43 PM, Shaun Fryer wrote: >>>> nice (though pretty convoluted). the following breaks it. >>>> >>>> "key=\'stuff\'" = "value1=\'stuff\',value2=\'more ;stuff\'" ; comment >>>> with " ' and ; >>>> -- >>>> Shaun Fryer >>>> cell: 1-647-709-6509 >>>> voip: 1-647-723-2729 >>>> >>>> >>>> >>>> >>>> On Wed, Mar 9, 2011 at 2:38 PM, Rob Janes wrote: >>>>> this strips off the comment >>>>> >>>>> #!/usr/bin/env perl >>>>> >>>>> use strict; >>>>> use warnings; >>>>> >>>>> while () { >>>>> ?chomp; >>>>> >>>>> ?print "\n\n================\nline: $_\n"; >>>>> >>>>> ?if (m{ >>>>> ? ? ? ?^ >>>>> ? ? ? ?( >>>>> ? ? ? ? ?(?:[^\\"';\s]| >>>>> ? ? ? ? ? ?\\.| >>>>> ? ? ? ? ? ?\s| >>>>> ? ? ? ? ? ?"(?:[^"\\]|\\.)*"| >>>>> ? ? ? ? ? ?'(?:[^'\\]|\\.)*' >>>>> ? ? ? ? ?)+ >>>>> ? ? ? ?) >>>>> ? ? ? ?(?:\s*;\s*(.*))? >>>>> ? ? ? ?$ >>>>> ? ? ? ?}x) >>>>> ?{ >>>>> ? ?my ($words, $comment) = ($1, $2); >>>>> ? ?$comment = "" unless defined($comment); >>>>> ? ?print "matches!\n"; >>>>> >>>>> ? ?print "data is $words\ncomment is $comment\n"; >>>>> ?} >>>>> ?else >>>>> ?{ >>>>> ? ? print "match FAILED!\n"; >>>>> ?} >>>>> } >>>>> >>>>> __DATA__ >>>>> key="value" >>>>> key=value >>>>> key="value;" >>>>> key="value1;value2" >>>>> key="value1;value2" ? ? ; comment >>>>> key='value1;value2' ? ? ; comment >>>>> "key"="value1" >>>>> "key"="value1" ? ? ? ? ?; comment >>>>> "key"="value1;value2" >>>>> "key"="value1;value2" ? ; comment >>>>> "key"="val\"ue1;value2" >>>>> "key"="val\"ue1;value2" ; comment >>>>> "key"='val\'ue1;value2' ; comment >>>>> "key"='val\"ue1;value2' ; comment >>>>> key="this=that" ; an = in the value >>>>> key="value" ; a " in the comment >>>>> this is a title ? ; and this is a comment >>>>> >>>>> >>>>> On Wed, Mar 9, 2011 at 2:33 PM, Shaun Fryer wrote: >>>>>> Indeed. Or "key=\'stuff\'"="value1=\'stuff\',value2=\'more ;stuff\'" ; >>>>>> comment with " ' and ; >>>>>> -- >>>>>> Shaun Fryer >>>>>> cell: 1-647-709-6509 >>>>>> voip: 1-647-723-2729 >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> On Wed, Mar 9, 2011 at 2:30 PM, Rob Janes wrote: >>>>>>> there's >>>>>>> >>>>>>> key="this=that" ?; an = in the value >>>>>>> >>>>>>> and >>>>>>> >>>>>>> key="value" ; a " in the comment >>>>>>> >>>>>>> On Wed, Mar 9, 2011 at 2:16 PM, Shaun Fryer wrote: >>>>>>>> my $strip = qr{;[^\;]+$}; >>>>>>>> while () { >>>>>>>> ? ?chomp; >>>>>>>> ? ?my ($key, $val) = split /=/; >>>>>>>> ? ?my ($quote) = ($val =~ m{^(["'])}g); >>>>>>>> ? ?if ($quote) { >>>>>>>> ? ? ? ?($val) = ($val =~ m{^($quote[^\b]+($quote))}g); >>>>>>>> ? ?} >>>>>>>> ? ?else { >>>>>>>> ? ? ? ?$val =~ s/$strip//; >>>>>>>> ? ?} >>>>>>>> ? ?print $key, '=', $val, "\n"; >>>>>>>> } >>>>>>>> >>>>>>>> __DATA__ >>>>>>>> key="value" >>>>>>>> key=value >>>>>>>> key="vlue;" >>>>>>>> key="value1;value2" >>>>>>>> key="value1;value2" ? ? ; comment >>>>>>>> key='value1;value2' ? ? ; comment >>>>>>>> "key"="value1" >>>>>>>> "key"="value1" ? ? ? ? ?; comment >>>>>>>> "key"="value1;value2" >>>>>>>> "key"="value1;value2" ? ; comment >>>>>>>> "key"="val\"ue1;value2" >>>>>>>> "key"="val\"ue1;value2" ; comment >>>>>>>> "key"='val\'ue1;value2' ; comment >>>>>>>> "key"='val\"ue1;value2' ; comment >>>>>>>> -- >>>>>>>> Shaun Fryer >>>>>>>> cell: 1-647-709-6509 >>>>>>>> voip: 1-647-723-2729 >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> On Wed, Mar 9, 2011 at 2:12 PM, ? wrote: >>>>>>>>> Doesn't work. ?Output: >>>>>>>>> >>>>>>>>> ---- >>>>>>>>> key="value" >>>>>>>>> key=value >>>>>>>>> key="value1 >>>>>>>>> key="value1;value2" >>>>>>>>> key='value1;value2' >>>>>>>>> "key"="value1" >>>>>>>>> "key"="value1" >>>>>>>>> "key"="value1 >>>>>>>>> "key"="value1;value2" >>>>>>>>> "key"="val\"ue1 >>>>>>>>> "key"="val\"ue1;value2" >>>>>>>>> "key"='val\'ue1;value2' >>>>>>>>> "key"='val\"ue1;value2' >>>>>>>>> ---- >>>>>>>>> >>>>>>>>> Look at line 3. >>>>>>>>> >>>>>>>>> Also it wouldn't catch a trailing semicolon with nothing after it. >>>>>>>>> >>>>>>>>> Here's a quick and dirty improvement, but it will still have problems: >>>>>>>>> >>>>>>>>> my $strip = qr{;[^\;\"\']*$}; >>>>>>>>> while () { >>>>>>>>> ? ?chomp; >>>>>>>>> ? ?$_ =~ s/$strip//; >>>>>>>>> ? ?print $_, "\n"; >>>>>>>>> } >>>>>>>>> >>>>>>>>> >>>>>>>>> Here's the way I would do it: >>>>>>>>> >>>>>>>>> ---- >>>>>>>>> while () { >>>>>>>>> ? ?chomp; >>>>>>>>> >>>>>>>>> ? ?my $stripped; >>>>>>>>> ? ?my $quotechar = ""; >>>>>>>>> ? ?foreach my $char (split(//, $_)) { >>>>>>>>> ? ? ? ?if ($quotechar) { # We're currently quoted >>>>>>>>> ? ? ? ? ? ?if ($char eq $quotechar) { # end of quote >>>>>>>>> ? ? ? ? ? ? ? ?$quotechar = ""; >>>>>>>>> ? ? ? ? ? ?} >>>>>>>>> ? ? ? ?} else { # We're not currently quoted >>>>>>>>> ? ? ? ? ? ?if ($char eq ';') { # The comment has begun! >>>>>>>>> ? ? ? ? ? ? ? ?last(); >>>>>>>>> ? ? ? ? ? ?} elsif ($char eq '"' || $char eq "'") { # start of quote >>>>>>>>> ? ? ? ? ? ? ? ?$quotechar = $char; >>>>>>>>> ? ? ? ? ? ?} >>>>>>>>> ? ? ? ?} >>>>>>>>> ? ? ? ?$stripped .= $char; >>>>>>>>> ? ?} >>>>>>>>> ? ?print "$stripped\n"; >>>>>>>>> } >>>>>>>>> >>>>>>>>> __DATA__ >>>>>>>>> key="value" >>>>>>>>> key=value >>>>>>>>> key="value1;value2" >>>>>>>>> key="value1;value2" ? ? ; comment >>>>>>>>> key='value1;value2' ? ? ; comment >>>>>>>>> "key"="value1" >>>>>>>>> "key"="value1" ? ? ? ? ?; comment >>>>>>>>> "key"="value1;value2" >>>>>>>>> "key"="value1;value2" ? ; comment >>>>>>>>> "key"="val\"ue1;value2" >>>>>>>>> "key"="val\"ue1;value2" ; comment >>>>>>>>> "key"='val\'ue1;value2' ; comment >>>>>>>>> "key"='val\"ue1;value2' ; comment >>>>>>>>> ---- >>>>>>>>> >>>>>>>>> On Wed, 9 Mar 2011 13:48:39 -0500, Shaun Fryer wrote: >>>>>>>>>> >>>>>>>>>> my $strip = qr{;[^\;]+$}; >>>>>>>>>> while () { >>>>>>>>>> ? ?chomp; >>>>>>>>>> ? ?$_ =~ s/$strip//; >>>>>>>>>> ? ?print $_, "\n"; >>>>>>>>>> } >>>>>>>>>> >>>>>>>>>> __DATA__ >>>>>>>>>> key="value" >>>>>>>>>> key=value >>>>>>>>>> key="value1;value2" >>>>>>>>>> key="value1;value2" ? ? ; comment >>>>>>>>>> key='value1;value2' ? ? ; comment >>>>>>>>>> "key"="value1" >>>>>>>>>> "key"="value1" ? ? ? ? ?; comment >>>>>>>>>> "key"="value1;value2" >>>>>>>>>> "key"="value1;value2" ? ; comment >>>>>>>>>> "key"="val\"ue1;value2" >>>>>>>>>> "key"="val\"ue1;value2" ; comment >>>>>>>>>> "key"='val\'ue1;value2' ; comment >>>>>>>>>> "key"='val\"ue1;value2' ; comment >>>>>>>>>> >>>>>>>>>> -- >>>>>>>>>> Shaun Fryer >>>>>>>>>> cell: 1-647-709-6509 >>>>>>>>>> voip: 1-647-723-2729 >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> On Wed, Mar 9, 2011 at 1:39 PM, Fulko Hew wrote: >>>>>>>>>>> >>>>>>>>>>> On Wed, Mar 9, 2011 at 1:14 PM, Rob Janes wrote: >>>>>>>>>>>> >>>>>>>>>>>> here's one that dequotes the key and value ... >>>>>>>>>>> >>>>>>>>>>> Thanks for the ideas, but.. >>>>>>>>>>> the issue isn't with extracting the keys and the values (and dequoting >>>>>>>>>>> them), >>>>>>>>>>> the task was only to strip trailing comments (while obeying quoted >>>>>>>>>>> strings) >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> _______________________________________________ >>>>>>>>>>> toronto-pm mailing list >>>>>>>>>>> toronto-pm at pm.org >>>>>>>>>>> http://mail.pm.org/mailman/listinfo/toronto-pm >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>> _______________________________________________ >>>>>>>>>> toronto-pm mailing list >>>>>>>>>> toronto-pm at pm.org >>>>>>>>>> http://mail.pm.org/mailman/listinfo/toronto-pm >>>>>>>>> >>>>>>>>> _______________________________________________ >>>>>>>>> toronto-pm mailing list >>>>>>>>> toronto-pm at pm.org >>>>>>>>> http://mail.pm.org/mailman/listinfo/toronto-pm >>>>>>>>> >>>>>>>> _______________________________________________ >>>>>>>> toronto-pm mailing list >>>>>>>> toronto-pm at pm.org >>>>>>>> http://mail.pm.org/mailman/listinfo/toronto-pm >>>>>>>> >>>>>>> >>>>>> >>>>> >>>> >>> >> > From richard.dice at gmail.com Wed Mar 9 11:42:23 2011 From: richard.dice at gmail.com (Richard Dice) Date: Wed, 9 Mar 2011 14:42:23 -0500 Subject: [tpm] I wish I was better at regex's In-Reply-To: References: Message-ID: Those are getting closer, but honestly this can go way beyond the realm of what regexps can provide. For example, the text in the comment area... In theory, it could contain text like "key"="Val\"ue" ; tricked you!! To fully, correctly solve this you need a full parser. Like Parse::RecDescent Which is like hitting a melon with an atomic bomb. If you have ANY foreknowledge of the sorts of files you are going to receive and the kind of comments they will (NOT "might, theoretically") contain, just cook up some cheap-ass line mangling logic, maybe using some regexps, maybe some substr and index and rindex. Sent from my iPhone On 2011-03-09, at 2:32 PM, Fulko Hew wrote: > On Wed, Mar 9, 2011 at 2:29 PM, Shaun Fryer wrote: >> >> It's very difficult to do without matching quotes, and hence key/value >> pairs. For instance, what if the comment contains a quote, just as the >> quotes may contain a semi-colon? In this case I've sidestepped the >> problem of escaped quotes by using a word-boundary (\b) match inside >> any matched quotes. the side effect of this, is that any spaces inside >> the quotes will count... >> >> good luck if you can do it without matching keys/values/quotes. I've >> already got beers riding on the solution. ;) > > Thats why I then looked at things like: > > Regexp::Common::balanced > Regexp::Common::comment > > but I couldn't figure out how to apply them. > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm From uri at StemSystems.com Wed Mar 9 12:36:13 2011 From: uri at StemSystems.com (Uri Guttman) Date: Wed, 09 Mar 2011 15:36:13 -0500 Subject: [tpm] I wish I was better at regex's In-Reply-To: (Richard Dice's message of "Wed\, 9 Mar 2011 14\:42\:23 -0500") References: Message-ID: <87d3m0vxoi.fsf@quad.sysarch.com> >>>>> "RD" == Richard Dice writes: RD> Those are getting closer, but honestly this can go way beyond the RD> realm of what regexps can provide. For example, the text in the RD> comment area... In theory, it could contain text like RD> "key"="Val\"ue" ; tricked you!! RD> To fully, correctly solve this you need a full parser. Like RD> Parse::RecDescent RD> Which is like hitting a melon with an atomic bomb. you don't need a full parser. this can be done with Text::Balanced from the looks of it. getting a regex to do it is insane though. just scan from the left for each possible field. get the key=value with possible quoted values (i don't have the spec in my head), then check for a comment and skip/delete it. the module will handle escaped quotes and most anything you could legally put there. this is very easy when parsed properly and not easy with a regex. uri -- Uri Guttman ------ uri at stemsystems.com -------- http://www.sysarch.com -- ----- Perl Code Review , Architecture, Development, Training, Support ------ --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com --------- From janes.rob at gmail.com Wed Mar 9 12:36:46 2011 From: janes.rob at gmail.com (Rob Janes) Date: Wed, 9 Mar 2011 15:36:46 -0500 Subject: [tpm] I wish I was better at regex's In-Reply-To: References: Message-ID: i recall some compsci proof that regex cannot do nested pattern matching, like (xxx) or (xxx (yyy) zzz). for that you need a lalr parser, something like recdescent or whatever. however, regex can handle single depth quoted expressions. the regex might be long and ugly, but it can do it. so, shell quotation, ms ini file, c quotes, javascript quotes, xml, can all be parsed by a single regex expression. On Wed, Mar 9, 2011 at 2:42 PM, Richard Dice wrote: > Those are getting closer, but honestly this can go way beyond the realm of what regexps can provide. ?For example, the text in the comment area... In theory, it could contain text like > > ?"key"="Val\"ue" ; tricked you!! > > To fully, correctly solve this you need a full parser. ?Like Parse::RecDescent > > Which is like hitting a melon with an atomic bomb. > > If you have ANY foreknowledge of the sorts of files you are going to receive and the kind of comments they will (NOT "might, theoretically") contain, just cook up some cheap-ass line mangling logic, maybe using some regexps, maybe some substr and index and rindex. > > Sent from my iPhone > > On 2011-03-09, at 2:32 PM, Fulko Hew wrote: > >> On Wed, Mar 9, 2011 at 2:29 PM, Shaun Fryer wrote: >>> >>> It's very difficult to do without matching quotes, and hence key/value >>> pairs. For instance, what if the comment contains a quote, just as the >>> quotes may contain a semi-colon? In this case I've sidestepped the >>> problem of escaped quotes by using a word-boundary (\b) match inside >>> any matched quotes. the side effect of this, is that any spaces inside >>> the quotes will count... >>> >>> good luck if you can do it without matching keys/values/quotes. I've >>> already got beers riding on the solution. ;) >> >> Thats why I then looked at things like: >> >> Regexp::Common::balanced >> Regexp::Common::comment >> >> but I couldn't figure out how to apply them. >> _______________________________________________ >> toronto-pm mailing list >> toronto-pm at pm.org >> http://mail.pm.org/mailman/listinfo/toronto-pm > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm > From uri at StemSystems.com Wed Mar 9 13:14:30 2011 From: uri at StemSystems.com (Uri Guttman) Date: Wed, 09 Mar 2011 16:14:30 -0500 Subject: [tpm] I wish I was better at regex's In-Reply-To: (Rob Janes's message of "Wed\, 9 Mar 2011 15\:36\:46 -0500") References: Message-ID: <87zkp4uhc9.fsf@quad.sysarch.com> >>>>> "RJ" == Rob Janes writes: RJ> i recall some compsci proof that regex cannot do nested pattern RJ> matching, like (xxx) or (xxx (yyy) zzz). for that you need a lalr RJ> parser, something like recdescent or whatever. that is true for pure regexes. perl's latest can match nested pairs. it isn't trivial but the feature is in there and documented. regardless, this problem is very easy to solve with text::balanced and some basic code. just a single regex is the wrong solution. uri -- Uri Guttman ------ uri at stemsystems.com -------- http://www.sysarch.com -- ----- Perl Code Review , Architecture, Development, Training, Support ------ --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com --------- From jbl at jbldata.com Wed Mar 9 13:12:48 2011 From: jbl at jbldata.com (J. Bobby Lopez) Date: Wed, 9 Mar 2011 16:12:48 -0500 Subject: [tpm] Interested in Open Source solutions for Gantt Charts? In-Reply-To: References: Message-ID: If anyone uses Gantt Charts for project management, you might be interested in a nice little open source java-based tool which I've just found. Seems very straight forward (similar to mrproject, for those of you who've used that), and is available for linux/mac/win. Check it out here: http://www.ganttproject.biz/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From jbl at jbldata.com Wed Mar 9 13:19:11 2011 From: jbl at jbldata.com (J. Bobby Lopez) Date: Wed, 9 Mar 2011 16:19:11 -0500 Subject: [tpm] I wish I was better at regex's In-Reply-To: <87zkp4uhc9.fsf@quad.sysarch.com> References: <87zkp4uhc9.fsf@quad.sysarch.com> Message-ID: I would expect that you can just count the number of ';' instances in the string, and get the index of the last instance which resides after the last instance of the last single or double quote. If there are no quotes, then it's the first instance of ';'. On Wed, Mar 9, 2011 at 4:14 PM, Uri Guttman wrote: > >>>>> "RJ" == Rob Janes writes: > > RJ> i recall some compsci proof that regex cannot do nested pattern > RJ> matching, like (xxx) or (xxx (yyy) zzz). for that you need a lalr > RJ> parser, something like recdescent or whatever. > > that is true for pure regexes. perl's latest can match nested pairs. it > isn't trivial but the feature is in there and documented. regardless, > this problem is very easy to solve with text::balanced and some basic > code. just a single regex is the wrong solution. > > uri > > -- > Uri Guttman ------ uri at stemsystems.com -------- http://www.sysarch.com-- > ----- Perl Code Review , Architecture, Development, Training, Support > ------ > --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com--------- > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm > -------------- next part -------------- An HTML attachment was scrubbed... URL: From uri at StemSystems.com Wed Mar 9 13:30:09 2011 From: uri at StemSystems.com (Uri Guttman) Date: Wed, 09 Mar 2011 16:30:09 -0500 Subject: [tpm] I wish I was better at regex's In-Reply-To: (J. Bobby Lopez's message of "Wed\, 9 Mar 2011 16\:19\:11 -0500") References: <87zkp4uhc9.fsf@quad.sysarch.com> Message-ID: <87oc5kugm6.fsf@quad.sysarch.com> >>>>> "JBL" == J Bobby Lopez writes: JBL> I would expect that you can just count the number of ';' JBL> instances in the string, and get the index of the last instance JBL> which resides after the last instance of the last single or JBL> double quote.? If there are no quotes, then it's the first JBL> instance of ';'. that is backwards. it is much simpler to parse forwards. this is old school stuff that is done in assemblers and similar syntaxes with optional fields on a line. you scan allowed fields from left to right and it all is easy. uri -- Uri Guttman ------ uri at stemsystems.com -------- http://www.sysarch.com -- ----- Perl Code Review , Architecture, Development, Training, Support ------ --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com --------- From jbl at jbldata.com Wed Mar 9 13:36:38 2011 From: jbl at jbldata.com (J. Bobby Lopez) Date: Wed, 9 Mar 2011 16:36:38 -0500 Subject: [tpm] I wish I was better at regex's In-Reply-To: <87oc5kugm6.fsf@quad.sysarch.com> References: <87zkp4uhc9.fsf@quad.sysarch.com> <87oc5kugm6.fsf@quad.sysarch.com> Message-ID: Agreed, but in the event that you don't have a strict format for comments and key/value pairs (quotes/no quotes; comments with special characters/without), then you're still looking for the last instance of ';' outside of last (possible) quote, no? On Wed, Mar 9, 2011 at 4:30 PM, Uri Guttman wrote: > >>>>> "JBL" == J Bobby Lopez writes: > > JBL> I would expect that you can just count the number of ';' > JBL> instances in the string, and get the index of the last instance > JBL> which resides after the last instance of the last single or > JBL> double quote. If there are no quotes, then it's the first > JBL> instance of ';'. > > that is backwards. it is much simpler to parse forwards. this is old > school stuff that is done in assemblers and similar syntaxes with > optional fields on a line. you scan allowed fields from left to right > and it all is easy. > > uri > > -- > Uri Guttman ------ uri at stemsystems.com -------- http://www.sysarch.com-- > ----- Perl Code Review , Architecture, Development, Training, Support > ------ > --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com--------- > -------------- next part -------------- An HTML attachment was scrubbed... URL: From uri at StemSystems.com Wed Mar 9 13:43:16 2011 From: uri at StemSystems.com (Uri Guttman) Date: Wed, 09 Mar 2011 16:43:16 -0500 Subject: [tpm] I wish I was better at regex's In-Reply-To: (J. Bobby Lopez's message of "Wed\, 9 Mar 2011 16\:36\:38 -0500") References: <87zkp4uhc9.fsf@quad.sysarch.com> <87oc5kugm6.fsf@quad.sysarch.com> Message-ID: <87fwqwug0b.fsf@quad.sysarch.com> >>>>> "JBL" == J Bobby Lopez writes: JBL> Agreed, but in the event that you don't have a strict format for JBL> comments and key/value pairs (quotes/no quotes; comments with JBL> special characters/without), then you're still looking for the JBL> last instance of ';' outside of last (possible) quote, no? if you DON'T have a strict format, how can it be parsed and used by any program? you have to assume or know the rules. this is a config file that is already being parsed and used by some program. the OP wants to modify it with perl regexes which is the wrong solution. since it has a specification of some sort, it can be parsed and left to right parsing is the way to go. uri -- Uri Guttman ------ uri at stemsystems.com -------- http://www.sysarch.com -- ----- Perl Code Review , Architecture, Development, Training, Support ------ --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com --------- From stuart at morungos.com Wed Mar 9 13:53:45 2011 From: stuart at morungos.com (Stuart Watt) Date: Wed, 9 Mar 2011 16:53:45 -0500 Subject: [tpm] I wish I was better at regex's In-Reply-To: References: <87zkp4uhc9.fsf@quad.sysarch.com> Message-ID: <4D77F6E9.7060809@morungos.com> Sorry to chip in late, but this actually feels like a tokenizing problem, which is part-way to Richard's point. I do a lot of these, and there is a pattern in the perldocs, specifically under "What good is \G in a regular expression?" in perlfaq6. This would go something like this (*** warning untested code ***) while(1) { m{\G(\s*;[^\n]*))}gcx && do { }; # Don't print when matched a comment m{\G(=)}gcx && do { print $1; }; m{\G(\s+)}gcx && do { print $1; }; m{\G(\w+)}gcx && do { print $1; }; m{\G(\"(?:\\.|[^\\\"])*\")}gcx && do { print $1; }; m{\G(\'(?:\\.|[^\\\'])*\')}gcx && do { print $1; }; m{\G$}gcx && last; croak("Unprocessed input"); } print, of course, could be replaced to just drop the identified section of text somewhere, e.g., in an output array to be joined. This has the benefit that it isn't all one huge regex, but it is slower. Essentially, the idea is simple: \G represents the current position, and each line handles a different type of token at each position. This allows strings to be handled in separate regexes from words, comments, etc. This means comment handling can be separated from quote handling, which does improve maintainability. As has been said, it is possible to do this in a single regex (even nesting in Perl 5.10+) but the result can be an unreadable mess. Believe me, I've written some like that. There is also a significant risk of hitting serious performance issues. A complex regex, can quickly degrade if backtracking/lazy quantifiers aren't handled right, and you can end up with truly bad performance. The approach above will impose a small hit, but usually prevents pathologically bad matching. All the best Stuart On 09/03/2011 4:19 PM, J. Bobby Lopez wrote: > I would expect that you can just count the number of ';' instances in > the string, and get the index of the last instance which resides after > the last instance of the last single or double quote. If there are no > quotes, then it's the first instance of ';'. > > On Wed, Mar 9, 2011 at 4:14 PM, Uri Guttman > wrote: > > >>>>> "RJ" == Rob Janes > writes: > > RJ> i recall some compsci proof that regex cannot do nested pattern > RJ> matching, like (xxx) or (xxx (yyy) zzz). for that you need a > lalr > RJ> parser, something like recdescent or whatever. > > that is true for pure regexes. perl's latest can match nested > pairs. it > isn't trivial but the feature is in there and documented. regardless, > this problem is very easy to solve with text::balanced and some basic > code. just a single regex is the wrong solution. > > uri > > -- > Uri Guttman ------ uri at stemsystems.com > -------- http://www.sysarch.com -- > ----- Perl Code Review , Architecture, Development, Training, > Support ------ > --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com > --------- > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm > > > > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm -------------- next part -------------- An HTML attachment was scrubbed... URL: From jbl at jbldata.com Wed Mar 9 14:03:02 2011 From: jbl at jbldata.com (J. Bobby Lopez) Date: Wed, 9 Mar 2011 17:03:02 -0500 Subject: [tpm] I wish I was better at regex's In-Reply-To: <87fwqwug0b.fsf@quad.sysarch.com> References: <87zkp4uhc9.fsf@quad.sysarch.com> <87oc5kugm6.fsf@quad.sysarch.com> <87fwqwug0b.fsf@quad.sysarch.com> Message-ID: Then I suppose a rephrasing the question would be beneficial. Instead of: "Strip comments from lines while obeying quoted strings" .. maybe: "Rip key/value pairs from line, and disregard comments". Which would put the focus on the key/val pairs (with an opportunity to normalize them; convert them all to quoted values, for example), instead of focusing on stripping the comments away. On Wed, Mar 9, 2011 at 4:43 PM, Uri Guttman wrote: > >>>>> "JBL" == J Bobby Lopez writes: > > JBL> Agreed, but in the event that you don't have a strict format for > JBL> comments and key/value pairs (quotes/no quotes; comments with > JBL> special characters/without), then you're still looking for the > JBL> last instance of ';' outside of last (possible) quote, no? > > if you DON'T have a strict format, how can it be parsed and used by any > program? you have to assume or know the rules. this is a config file > that is already being parsed and used by some program. the OP wants to > modify it with perl regexes which is the wrong solution. since it has a > specification of some sort, it can be parsed and left to right parsing > is the way to go. > > uri > > -- > Uri Guttman ------ uri at stemsystems.com -------- http://www.sysarch.com-- > ----- Perl Code Review , Architecture, Development, Training, Support > ------ > --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com--------- > -------------- next part -------------- An HTML attachment was scrubbed... URL: From uri at StemSystems.com Wed Mar 9 14:45:31 2011 From: uri at StemSystems.com (Uri Guttman) Date: Wed, 09 Mar 2011 17:45:31 -0500 Subject: [tpm] I wish I was better at regex's In-Reply-To: (J. Bobby Lopez's message of "Wed\, 9 Mar 2011 17\:03\:02 -0500") References: <87zkp4uhc9.fsf@quad.sysarch.com> <87oc5kugm6.fsf@quad.sysarch.com> <87fwqwug0b.fsf@quad.sysarch.com> Message-ID: <87ei6fud4k.fsf@quad.sysarch.com> >>>>> "JBL" == J Bobby Lopez writes: JBL> Then I suppose a rephrasing the question would be beneficial.? JBL> Instead of: "Strip comments from lines while obeying quoted JBL> strings" JBL> .. maybe: JBL> "Rip key/value pairs from line, and disregard comments". JBL> Which would put the focus on the key/val pairs (with an JBL> opportunity to normalize them; convert them all to quoted values, JBL> for example), instead of focusing on stripping the comments away. sometimes rephrasing the problem helps a lot. in this case it didn't matter to me once i saw the complex regexes being tossed about like hand grenades! when that was happening it was obvious to me they were going down the wrong path. as i said elsewhere, this is an old problem solved long ago by parsing left to right with a proper parser (which can use regexes!). the format is very similar to assembler code lines. uri -- Uri Guttman ------ uri at stemsystems.com -------- http://www.sysarch.com -- ----- Perl Code Review , Architecture, Development, Training, Support ------ --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com --------- From janes.rob at gmail.com Wed Mar 9 21:44:19 2011 From: janes.rob at gmail.com (Rob Janes) Date: Thu, 10 Mar 2011 00:44:19 -0500 Subject: [tpm] I wish I was better at regex's In-Reply-To: <87ei6fud4k.fsf@quad.sysarch.com> References: <87zkp4uhc9.fsf@quad.sysarch.com> <87oc5kugm6.fsf@quad.sysarch.com> <87fwqwug0b.fsf@quad.sysarch.com> <87ei6fud4k.fsf@quad.sysarch.com> Message-ID: My ten line regex is a hand grenade? Sounds a bit like a monty python skit. Fulko did ask for a regex. Personally, I got nothing against regex, complex or not. One of the things I like about perl is that there's a million ways to do something. When somebody says something is wrong, even though it works, that just means they don't like it and that they personally would rather do it another way. There's no one right way to do things in perl. The regex solution is nice (imho), doesn't require any packages to be installed (works out of the box), is obvious if you know regex, is portable to any language with pcre, and is probably faster than all the other solutions posted or suggested. That regex doesn't use any features that slow perl down, it just uses basic regex. I've never used Text::Balanced before. Sounds like it's popular, but I gotta say the man page could be better written. In terms of time, it'd take me less time to write out a regex than it would to figure out that Text::Balanced man page and write some code with it, and I can just see a rinse and repeat cycle every time I got into it. All you Text::Balanced aficionados, would any of you like to put up a Text::Balanced solution to Fulko's problem? On Wed, Mar 9, 2011 at 5:45 PM, Uri Guttman wrote: >>>>>> "JBL" == J Bobby Lopez writes: > > ?JBL> Then I suppose a rephrasing the question would be beneficial. > ?JBL> Instead of: "Strip comments from lines while obeying quoted > ?JBL> strings" > > ?JBL> .. maybe: > > ?JBL> "Rip key/value pairs from line, and disregard comments". > > ?JBL> Which would put the focus on the key/val pairs (with an > ?JBL> opportunity to normalize them; convert them all to quoted values, > ?JBL> for example), instead of focusing on stripping the comments away. > > sometimes rephrasing the problem helps a lot. in this case it didn't > matter to me once i saw the complex regexes being tossed about like hand > grenades! when that was happening it was obvious to me they were going > down the wrong path. as i said elsewhere, this is an old problem solved > long ago by parsing left to right with a proper parser (which can use > regexes!). the format is very similar to assembler code lines. > > uri > > -- > Uri Guttman ?------ ?uri at stemsystems.com ?-------- ?http://www.sysarch.com -- > ----- ?Perl Code Review , Architecture, Development, Training, Support ------ > --------- ?Gourmet Hot Cocoa Mix ?---- ?http://bestfriendscocoa.com --------- > From fulko.hew at gmail.com Mon Mar 14 11:37:41 2011 From: fulko.hew at gmail.com (Fulko Hew) Date: Mon, 14 Mar 2011 14:37:41 -0400 Subject: [tpm] A 'must read' book In-Reply-To: References: Message-ID: Ordinarily, I rarely recommend books, but, I am sending this to all my friends, colleagues, and enemies. I think its that important. I just finished reading a book (recommended by an ex-colleague 'thanks Bob') I think it is FANTASTIC, and I say it is a 'must read'. Its called "Rework". It won't take too long, and if you have to buy it (some links are provided below) its not too expensive (~ $12.00) Personally, I just got an electronic copy from my local library to read (on my new Android tablet computer/eReader from Barnes and Noble (ask me about it)) If you read this book and you think it is: a) sacrilegiously revolutionary... then you desperately need to re-read it and practice it b) common sense... then you probably need to practice common sense more. c) full of stupid ideas... you have my sympathies If you get the impression that I REALLY REALLY LIKE this book, good! I went so far as to email the author and personally thank him for writing the book. He responded within 10 minutes! http://search.barnesandnoble.com/Rework/Jason-Fried/e/9780307463746 http://www.amazon.com/Rework-Jason-Fried/dp/0307463745 Fulko From mike at stok.ca Tue Mar 15 04:37:46 2011 From: mike at stok.ca (Mike Stok) Date: Tue, 15 Mar 2011 07:37:46 -0400 Subject: [tpm] March meeting Message-ID: <1E131E5C-7FB0-45E0-9822-C855F7C8B76D@stok.ca> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Phillip A D Smith will be talking about Bricolage this month, details at http://to.pm.org. The point of this email is to figure out what we would like to do after the meeting, We could go to the Spotted Dick again as it worked out quite well last month, or we could go somewhere else (my next choice within 5 minutes walk would be the Artful Dodger on Isabella). My inclination would be the Spotted Dick again, and I would like to hear what you all think / want. Regards, Mike - -- Mike Stok http://www.stok.ca/~mike/ The "`Stok' disclaimers" apply. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (Darwin) iEYEARECAAYFAk1/T4oACgkQnsTBwAWZE9pxpQCdH5MCWs6aG0LLa/8b5RlKba5F oo0AoIT/HaKOXfbeeOeEtZeVRcTIeuY8 =7muS -----END PGP SIGNATURE----- From jztam at yahoo.com Tue Mar 15 07:59:58 2011 From: jztam at yahoo.com (J Z Tam) Date: Tue, 15 Mar 2011 07:59:58 -0700 (PDT) Subject: [tpm] March meeting In-Reply-To: <1E131E5C-7FB0-45E0-9822-C855F7C8B76D@stok.ca> Message-ID: <476829.97497.qm@web57603.mail.re1.yahoo.com> I second that... quiet, well lit, good pub fare.? Spotted Dick is good. --- On Tue, 3/15/11, Mike Stok wrote: From: Mike Stok Subject: [tpm] March meeting To: tpm at to.pm.org Received: Tuesday, March 15, 2011, 7:37 AM -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Phillip A D Smith will be talking about Bricolage this month, details at http://to.pm.org. The point of this email is to figure out what we would like to do after the meeting,? We could go to the Spotted Dick again as it worked out quite well last month, or we could go somewhere else (my next choice within 5 minutes walk would be the Artful Dodger on Isabella).? My inclination would be the Spotted Dick again, and I would like to hear what you all think / want. Regards, Mike - -- Mike Stok http://www.stok.ca/~mike/ The "`Stok' disclaimers" apply. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (Darwin) iEYEARECAAYFAk1/T4oACgkQnsTBwAWZE9pxpQCdH5MCWs6aG0LLa/8b5RlKba5F oo0AoIT/HaKOXfbeeOeEtZeVRcTIeuY8 =7muS -----END PGP SIGNATURE----- _______________________________________________ toronto-pm mailing list toronto-pm at pm.org http://mail.pm.org/mailman/listinfo/toronto-pm -------------- next part -------------- An HTML attachment was scrubbed... URL: From arocker at Vex.Net Wed Mar 16 06:43:32 2011 From: arocker at Vex.Net (arocker at Vex.Net) Date: Wed, 16 Mar 2011 09:43:32 -0400 Subject: [tpm] A 'must read' book In-Reply-To: References: Message-ID: <0a5fdf35be285cde9d1b63ca68c61bd2.squirrel@mail.vex.net> > Its called "Rework". > I agree with Fulko. It's an "Up the Organisation" http://www.amazon.com/Up-Organization-Robert-Townsend/dp/0449205053 http://howtobeaclient.blogspot.com/2011/02/this-weeks-post-i-have-borrowed-with.html for the 21st. century. (The original's holding up pretty well, too.) From fulko.hew at gmail.com Fri Mar 18 07:42:27 2011 From: fulko.hew at gmail.com (Fulko Hew) Date: Fri, 18 Mar 2011 10:42:27 -0400 Subject: [tpm] How to find my class name Message-ID: I have the following (simplified, and artificial) scenario: package testClass; my $classvar = 'data'; sub getter { my ($class, $mode) = @_; $classvar = '' if ($mode eq 'reset'); return $classvar; } sub otherRoutine { print "I got this from the reset getter: ", getter('reset'), "\n"; } So in some cases code external to the class is going to want to call getter() this way: testClass->getter(); but internally I also need to call him. I can't just call getter() because the $mode will not be the 2nd param because I didn't pass in the 'class'. What would be the right way of calling my own method? Ie. If 'SUPER' is the parent class, is there equivalent magic for 'THISCLASS'? Fulko From dave.s.doyle at gmail.com Fri Mar 18 07:54:01 2011 From: dave.s.doyle at gmail.com (Dave Doyle) Date: Fri, 18 Mar 2011 10:54:01 -0400 Subject: [tpm] How to find my class name In-Reply-To: References: Message-ID: __PACKAGE__->getter() should do the trick. That way, if you change the class name it's still good. -- dave.s.doyle at gmail.com On Fri, Mar 18, 2011 at 10:42 AM, Fulko Hew wrote: > I have the following (simplified, and artificial) scenario: > > package testClass; > > my $classvar = 'data'; > > sub getter { > my ($class, $mode) = @_; > > $classvar = '' if ($mode eq 'reset'); > return $classvar; > } > > sub otherRoutine { > print "I got this from the reset getter: ", getter('reset'), "\n"; > } > > So in some cases code external to the class is > going to want to call getter() this way: > > testClass->getter(); > > but internally I also need to call him. > I can't just call getter() because the $mode will not be the 2nd param > because > I didn't pass in the 'class'. > > What would be the right way of calling my own method? > Ie. If 'SUPER' is the parent class, is there equivalent magic for > 'THISCLASS'? > > Fulko > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm > -------------- next part -------------- An HTML attachment was scrubbed... URL: From shlomif at iglu.org.il Fri Mar 18 08:47:01 2011 From: shlomif at iglu.org.il (Shlomi Fish) Date: Fri, 18 Mar 2011 17:47:01 +0200 Subject: [tpm] How to find my class name In-Reply-To: References: Message-ID: <201103181747.02333.shlomif@iglu.org.il> Hi, a few comments on your code. On Friday 18 Mar 2011 16:42:27 Fulko Hew wrote: > I have the following (simplified, and artificial) scenario: > > package testClass; 1. A package should always start with an uppercase letter. 2. You should add "use strict;" and "use warnings;" somewhere. Regards, Shlomi Fish > > my $classvar = 'data'; > > sub getter { > my ($class, $mode) = @_; > > $classvar = '' if ($mode eq 'reset'); > return $classvar; > } > > sub otherRoutine { > print "I got this from the reset getter: ", getter('reset'), "\n"; > } [SNIPPED] -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ Freecell Solver - http://fc-solve.berlios.de/ I don't believe in fairies. Oops! A fairy died. I don't believe in fairies. Oops! Another fairy died. Please reply to list if it's a mailing list post - http://shlom.in/reply . From fulko.hew at gmail.com Fri Mar 18 12:08:17 2011 From: fulko.hew at gmail.com (Fulko Hew) Date: Fri, 18 Mar 2011 15:08:17 -0400 Subject: [tpm] How to find my class name In-Reply-To: <201103181747.02333.shlomif@iglu.org.il> References: <201103181747.02333.shlomif@iglu.org.il> Message-ID: On Fri, Mar 18, 2011 at 11:47 AM, Shlomi Fish wrote: > Hi, > > a few comments on your code. > > On Friday 18 Mar 2011 16:42:27 Fulko Hew wrote: >> I have the following (simplified, and artificial) scenario: >> >> package testClass; > > 1. A package should always start with an uppercase letter. > > 2. You should add "use strict;" and "use warnings;" somewhere. I _did_ say it was an artificial scenario! The code I was showing was an interpretation of code that is actually programatically generated by my tool, but... I did take your advise. a) I added the strict and warning to the code generator's output, and although the generated code worked before, It did uncover some issue that makes my code generator output better ('more correct'). b) The package names generated are actually derived from the name of a 'thing' in the source file that the code generator consumes. I wanted the package name to be directly compatible with the source so that it was more intuitive to the user (relate-able). After reading words around the naming convention on packages, I decided that Perl pragma safety was more important than end-user intuitiveness, and so I now up-case the first letter of the input to generate the package name. Fulko -------------- next part -------------- An HTML attachment was scrubbed... URL: From legrady at gmail.com Fri Mar 18 17:43:19 2011 From: legrady at gmail.com (Tom Legrady) Date: Fri, 18 Mar 2011 20:43:19 -0400 Subject: [tpm] How to find my class name In-Reply-To: References: <201103181747.02333.shlomif@iglu.org.il> Message-ID: I wouldn't call this a class It doesn't ever instantiate an instance of the class -- no constructor. One doesn't access methods through the object. It's more of a package consisting purely of a shared package variable, $classvar, and subroutines that reference it. Since you never reference the class name, invoke it as testClass::getter $mode On Fri, Mar 18, 2011 at 3:08 PM, Fulko Hew wrote: > > > On Fri, Mar 18, 2011 at 11:47 AM, Shlomi Fish wrote: > > Hi, > > > > a few comments on your code. > > > > On Friday 18 Mar 2011 16:42:27 Fulko Hew wrote: > >> I have the following (simplified, and artificial) scenario: > >> > >> package testClass; > > > > 1. A package should always start with an uppercase letter. > > > > 2. You should add "use strict;" and "use warnings;" somewhere. > > I _did_ say it was an artificial scenario! > > The code I was showing was an interpretation of code > that is actually programatically generated by my tool, > but... I did take your advise. > > a) I added the strict and warning to the code generator's output, > and although the generated code worked before, It did uncover > some issue that makes my code generator output better > ('more correct'). > > b) The package names generated are actually derived from the name > of a 'thing' in the source file that the code generator consumes. > > I wanted the package name to be directly compatible with the > source so that it was more intuitive to the user (relate-able). > > After reading words around the naming convention on packages, > I decided that Perl pragma safety was more important than > end-user intuitiveness, and so I now up-case the first letter > of the input to generate the package name. > > Fulko > > > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From legrady at gmail.com Fri Mar 18 17:44:39 2011 From: legrady at gmail.com (Tom Legrady) Date: Fri, 18 Mar 2011 20:44:39 -0400 Subject: [tpm] How to find my class name In-Reply-To: References: <201103181747.02333.shlomif@iglu.org.il> Message-ID: oops, hit the return key too early ... invoke it as testClass::getter( $mode ) and there will only be one argument Tom On Fri, Mar 18, 2011 at 8:43 PM, Tom Legrady wrote: > I wouldn't call this a class > > It doesn't ever instantiate an instance of the class -- no constructor. > > One doesn't access methods through the object. > > It's more of a package consisting purely of a shared package variable, > $classvar, and subroutines that reference it. Since you never reference the > class name, invoke it as > > testClass::getter $mode > > On Fri, Mar 18, 2011 at 3:08 PM, Fulko Hew wrote: > >> >> >> On Fri, Mar 18, 2011 at 11:47 AM, Shlomi Fish >> wrote: >> > Hi, >> > >> > a few comments on your code. >> > >> > On Friday 18 Mar 2011 16:42:27 Fulko Hew wrote: >> >> I have the following (simplified, and artificial) scenario: >> >> >> >> package testClass; >> > >> > 1. A package should always start with an uppercase letter. >> > >> > 2. You should add "use strict;" and "use warnings;" somewhere. >> >> I _did_ say it was an artificial scenario! >> >> The code I was showing was an interpretation of code >> that is actually programatically generated by my tool, >> but... I did take your advise. >> >> a) I added the strict and warning to the code generator's output, >> and although the generated code worked before, It did uncover >> some issue that makes my code generator output better >> ('more correct'). >> >> b) The package names generated are actually derived from the name >> of a 'thing' in the source file that the code generator consumes. >> >> I wanted the package name to be directly compatible with the >> source so that it was more intuitive to the user (relate-able). >> >> After reading words around the naming convention on packages, >> I decided that Perl pragma safety was more important than >> end-user intuitiveness, and so I now up-case the first letter >> of the input to generate the package name. >> >> Fulko >> >> >> _______________________________________________ >> toronto-pm mailing list >> toronto-pm at pm.org >> http://mail.pm.org/mailman/listinfo/toronto-pm >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mike at stok.ca Sat Mar 19 15:47:16 2011 From: mike at stok.ca (Mike Stok) Date: Sat, 19 Mar 2011 18:47:16 -0400 Subject: [tpm] April Meeting - volunteers or suggestions wanted Message-ID: <7574124C-EBB8-4A55-850E-9DAB7DDCF14A@stok.ca> I am shaking the bushes again for people willing to provide the technical content for the April meeting (28 April). Last year we did have a springtime lightning-talk-like session in March (http://to.pm.org/2010/03/25/March_Madness.html) and if people like that I'm happy to do it. If that's not what you'd like to see then can you propose something better to the list? As there's more than a month to go until April's meeting this might be the time to prepare talks if there are people with things they'd like to hear and people who want to present something but haven't got a topic. If you're just bursting to present something then let me know and we can schedule it somehow... Actions I'm looking for: People suggesting topics for April People volunteering to talk later in the year People volunteering topics, possibly for other people to talk about ... Mike -- Mike Stok http://www.stok.ca/~mike/ The "`Stok' disclaimers" apply. -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part URL: From olaf at vilerichard.com Sun Mar 20 05:30:33 2011 From: olaf at vilerichard.com (Olaf Alders) Date: Sun, 20 Mar 2011 08:30:33 -0400 Subject: [tpm] Google Summer of Code Message-ID: <107103BC-5316-4921-A46B-D7F6AF1D6805@vilerichard.com> Earlier this year there was some talk of Google Summer of Code, mentoring etc and how TPM could get involved. It turns out that the MetaCPAN project, which came out of some of our efforts late last year now has an interested student, who is putting together a GSoC proposal. So, in a roundabout way, TPM could be involved with GSoC. His proposal ideas are listed here: http://blogs.perl.org/users/mo/2011/03/metacpan-call-for-features.html Feel free to comment on the feature set etc. Olaf -- Olaf Alders olaf at vilerichard.com http://vilerichard.com -- folk rock http://twitter.com/vilerichard http://cdbaby.com/cd/vilerichard From arocker at Vex.Net Sun Mar 20 06:45:04 2011 From: arocker at Vex.Net (arocker at Vex.Net) Date: Sun, 20 Mar 2011 09:45:04 -0400 Subject: [tpm] Google Summer of Code In-Reply-To: <107103BC-5316-4921-A46B-D7F6AF1D6805@vilerichard.com> References: <107103BC-5316-4921-A46B-D7F6AF1D6805@vilerichard.com> Message-ID: <5d2e386198282c934d1bc5a75faf27bd.squirrel@mail.vex.net> > > http://blogs.perl.org/users/mo/2011/03/metacpan-call-for-features.html > > Feel free to comment on the feature set etc. > In order to prevent "feeping creaturitis", try to define the MINIMUN feature set that will produce a worthwhile product. That should give him a reasonable goal at which to aim, and prevent a waste of time on non-esentials. "Nice-to-have"s can always be added to v 2.0. From olaf at vilerichard.com Sun Mar 20 10:07:24 2011 From: olaf at vilerichard.com (Olaf Alders) Date: Sun, 20 Mar 2011 13:07:24 -0400 Subject: [tpm] Google Summer of Code In-Reply-To: <5d2e386198282c934d1bc5a75faf27bd.squirrel@mail.vex.net> References: <107103BC-5316-4921-A46B-D7F6AF1D6805@vilerichard.com> <5d2e386198282c934d1bc5a75faf27bd.squirrel@mail.vex.net> Message-ID: On 2011-03-20, at 9:45 AM, arocker at vex.net wrote: >> >> http://blogs.perl.org/users/mo/2011/03/metacpan-call-for-features.html >> >> Feel free to comment on the feature set etc. >> > > In order to prevent "feeping creaturitis", try to define the MINIMUN > feature set that will produce a worthwhile product. That should give him a > reasonable goal at which to aim, and prevent a waste of time on > non-esentials. "Nice-to-have"s can always be added to v 2.0. I should have asked to comment on the blog, so that he gets the feedback personally. :) This is just a "wish list" and the actual proposal will only have a subset of what he's talking about here. The idea is to be creative and then whittle it down from "nice to have" to "need to have". Olaf -- Olaf Alders olaf at vilerichard.com http://vilerichard.com -- folk rock http://twitter.com/vilerichard http://cdbaby.com/cd/vilerichard From stuart at morungos.com Mon Mar 21 14:09:07 2011 From: stuart at morungos.com (Stuart Watt) Date: Mon, 21 Mar 2011 17:09:07 -0400 Subject: [tpm] Possible opening for a Perl developer Message-ID: <4D87BE73.7010804@morungos.com> Hi folks, There is likely to be an opening available for a Perl developer in the team where I currently work, in the new few weeks. The role will likely involve the following main duties: * Web application development using Perl, Catalyst, and DBIx::Class * SQL, especially MySQL and Microsoft SQL Server * Parsing/analyzing a wide variety of languages, using grammars and regular expressions Some knowledge of, or interest in, the following would be useful: * Information retrieval frameworks, e.g., Lucene * HTML, CSS, and JavaScript toolkits such as Dojo * Perl on Windows * XML/XSLT and Perl API's for them * Subversion source code management * Trac project tracking * Continuous integration using Buildbot * The Nullsoft installer system If you know of anyone who may be interested, please feel free to pass this on and suggest that they might want to get in touch. The company is Information Balance, at http://www.infobal.com/, and is based in midtown Toronto, at Yonge and St. Clair, steps from St. Clair subway. All the best Stuart -- stuart at morungos.com / swatt at infobal.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From mike at stok.ca Tue Mar 22 04:21:45 2011 From: mike at stok.ca (Mike Stok) Date: Tue, 22 Mar 2011 07:21:45 -0400 Subject: [tpm] Fwd: UG News: Free to Choose Deal - Save 50% - All revenue goes to Japanese relief effort. References: <1300777396.21670.0.981296@post.oreilly.com> Message-ID: <5D40FEA9-068F-40A5-A515-4520BE08DC6C@stok.ca> View in Browser. Forward this announcement to your user group or a friend. Support Japanese Disaster Relief *Free to Choose* Ebook & Video Deal of the Day - Save 50% Enter code DDJPN in the O'Reilly cart. O'Reilly, No Starch Press, and Tidbits will donate all revenues, less author royalties, from today's "Deal of the Day" sales to the Japanese Red Cross Society. Thanks to the Internet, we understand more deeply than ever that everyone on the planet is connected. The disasters that have hit Japan feel close to home, and those of us at O'Reilly, No Starch, and Tidbits want to do something to help the Japanese people recover and rebuild. We know many of you do, too. Working with the O'Reilly Tokyo office, we will ensure that your valued contribution goes to the relief of those most in need. We'll update the total amount donated throughout the day, as well as the final amount. New and Bestselling from O'Reilly: Learning Android Was: $27.99 Now: $13.99 (Save 50%) Programming Amazon EC2 Was: $27.99 Now: $13.99 (Save 50%) HTML5: Up and Running Was: $23.99 Now: $11.99 (Save 50%) JavaScript: The Good Parts Was: $23.99 Now: $11.99 (Save 50%) R Cookbook Was: $31.99 Now: $15.99 (Save 50%) Arduino Cookbook Was: $31.99 Now: $15.99 (Save 50%) Make: Arduino Bots and Gadgets Was: $27.99 Now: $13.99 (Save 50%) Programming iOS 4 - Early Release Was: $35.99 Now: $17.99 (Save 50%) Strata Conference 2011: Complete Video Compilation Was: $399.99 Now: $199.99 (Save 50%) McCullough and Berglund on Mastering Git Was: $49.99 Now: $24.99 (Save 50%) No Starch: The Book of Audacity Was: $27.95 Now: $13.97 (Save 50%) Eloquent JavaScript Was: $23.95 Now: $11.97 (Save 50%) Learn You a Haskell for Great Good! Was: $35.95 Now: $17.97 (Save 50%) Art of LEGO MINDSTORMS NXT-G Prog Was: $23.95 Now: $11.97 (Save 50%) Gray Hat Python Was: $31.95 Now: $15.97 (Save 50%) Tidbits: Take Control of iPhone and iPod touch Networking & Security, iOS 4 Was: $15.00 Now: $7.50 (Save 50%) Take Control of iPad Networking & Security Was: $15.00 Now: $7.50 (Save 50%) Take Control of iPhone Basics, iOS 4 Edition Was: $10.00 Now: $5.00 (Save 50%) Take Control of Mail on the iPad, iPhone, and iPod touch, 2nd Ed. Was: $10.00 Now: $5.00 (Save 50%) Take Control of Apple Mail in Snow Leopard Was: $15.00 Now: $7.50 (Save 50%) See more books & videos > You are receiving this email because you are a User Group contact with O'Reilly Media. Forward this announcement. If you would like to stop receiving these newsletters or announcements from O'Reilly, send an email to marsee at oreilly.com. O'Reilly Media, Inc. 1005 Gravenstein Highway North, Sebastopol, CA 95472 (707) 827-7000 > -- Mike Stok http://www.stok.ca/~mike/ The "`Stok' disclaimers" apply. -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part URL: From mike at stok.ca Tue Mar 22 04:45:27 2011 From: mike at stok.ca (Mike Stok) Date: Tue, 22 Mar 2011 07:45:27 -0400 Subject: [tpm] =?windows-1252?q?Open_Source_Bridge_conference_June_21=9624?= =?windows-1252?q?=2C_2011=2C_in_Portland=2C_Oregon=2E?= Message-ID: <8AF8BB9D-3E15-45B2-8257-2AB186C5270E@stok.ca> This was sent to to.pm.org's controller. If there is any interest in the conference then to.pm.org can raffle off a pass to the conference. Let me know off-list if you are interested - if there is interest then we can raffle off the pass at a meeting. Mike Open Source Bridge http://opensourcebridge.org Open Source Bridge is a conference for people who work with open source technologies. It will take place June 21?24, 2011, in Portland, Oregon. The conference includes five tracks focused on connecting projects and experiences across different areas of open source. The schedule includes three days of traditional conference presentations, a day of free-form unconference sessions, and our 24-hour Hacker Lounge. You?ll find relevant information whether you write web apps, tinker with operating system internals, create hardware, run a business, write documentation, or contribute to open source in other ways. We're seeking presentation proposals through March 31st. Read our Call for Proposals here: http://opensourcebridge.org/call-for-proposals As a user group member, you can use the coupon code "osbugluv" to register at a discounted rate of $200 when you select either an Early Bird Registration (through April 15th), or a Regular Registration (after April 15th). Learn more and register at http://opensourcebridge.org/attend/ The conference is run entirely by volunteers and all proceeds from conference registration and sponsorship go directly to the costs of the conference. Visit http://opensourcebridge.org/ to learn more about the conference, see our session proposals, and register to attend. Thanks! -- Mike Stok http://www.stok.ca/~mike/ The "`Stok' disclaimers" apply. -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part URL: From fulko.hew at gmail.com Tue Mar 22 11:22:31 2011 From: fulko.hew at gmail.com (Fulko Hew) Date: Tue, 22 Mar 2011 14:22:31 -0400 Subject: [tpm] use from a local directory Message-ID: I don't know if I'm doing this right, or in the best manner... a) I have a compiler that generates Perl classes/source files based on data you feed it. b) People then write applications that 'include' those source files. Right now I have been using (for example) 'require "module1.pm";' in the applications. Which is great as long as I don't need to have the application run out of a non-current-working-directory. But now I have a situation where the generated modules have 'use constant' in them and I need to have the callers be able to use those constants easily. At the moment they need to do $x = Module1::CONSTANT_1(); in order for it to work. Something more natural would be $x = Module1::CONSTANT_1; ie. without the parens. To do that I need to use export/import (right?) And the only way to do that is something like 'use module qw/CONSTANT_1/; But then I'm using USE, not REQUIRE, and then the modules need to be installed in a standard directory... and the problem then mushrooms. Then I find out about 'use lib', but it only knows about explicitly defined directories. And 'use lib' isn't any different than didling the @INC variable anyway. And there doesn't seem to be an easy way of didling either to get it to include the 'invoked' directory (only the current-working-dirctory). I figure its easier to ship the executable and its modules in a single directory, than to ship the executable (where the user can put it anywhere they want) and then force the user to 'install' the remaining modules. Whats a guy to do? (Ah, statically compiled executables sure are looking easy right about now!) Comments? Fulko -------------- next part -------------- An HTML attachment was scrubbed... URL: From fulko.hew at gmail.com Tue Mar 22 11:26:50 2011 From: fulko.hew at gmail.com (Fulko Hew) Date: Tue, 22 Mar 2011 14:26:50 -0400 Subject: [tpm] use from a local directory In-Reply-To: References: Message-ID: On Tue, Mar 22, 2011 at 2:22 PM, Fulko Hew wrote: > I don't know if I'm doing this right, or in the best manner... > And... if I get all this to work... Since a file can contain multiple packages, how can the import discriminate between constants from one package versus the others in the use/require'd file? -------------- next part -------------- An HTML attachment was scrubbed... URL: From uri at StemSystems.com Tue Mar 22 11:38:49 2011 From: uri at StemSystems.com (Uri Guttman) Date: Tue, 22 Mar 2011 14:38:49 -0400 Subject: [tpm] use from a local directory In-Reply-To: (Fulko Hew's message of "Tue\, 22 Mar 2011 14\:22\:31 -0400") References: Message-ID: <87vczb3squ.fsf@quad.sysarch.com> >>>>> "FH" == Fulko Hew writes: FH> But now I have a situation where the generated modules have 'use FH> constant' in them and I need to have the callers be able to use FH> those constants easily. FH> At the moment they need to do $x = Module1::CONSTANT_1(); in order FH> for it to work. Something more natural would be $x = FH> Module1::CONSTANT_1; ie. without the parens. FH> To do that I need to use export/import (right?) Module1::CONSTANT_1() is fully qualified name so it doesn't need importing. if you import something, you only see the last part of the name (CONSTANT_1) in your current symbol table. you seem to have cross over those two concepts. FH> And the only way to do that is something like 'use module? qw/CONSTANT_1/; no, you could have them exported by default so you wouldn't need the qw// part. FH> But then I'm using USE, not REQUIRE, and then the modules need to FH> be installed in a standard directory... and the problem then FH> mushrooms. use and require do the same searching in the same dirs. the only differences are that require is run time vs compile time for use and use will call the import method on the loaded class. you can't import with require. FH> Then I find out about 'use lib', but it only knows about FH> explicitly defined directories.? And 'use lib' isn't any different FH> than didling the @INC variable anyway.? And there doesn't seem to FH> be an easy way of didling either to get it to include the FH> 'invoked' directory (only the current-working-dirctory). the dirs have nothing do to with this. it is the compile time vs runtime and importing that matters. what is wrong with having the users do a use line? make all your constants export by default (in @EXPORT) and you have a simple interface. uri -- Uri Guttman ------ uri at stemsystems.com -------- http://www.sysarch.com -- ----- Perl Code Review , Architecture, Development, Training, Support ------ --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com --------- From uri at StemSystems.com Tue Mar 22 11:42:35 2011 From: uri at StemSystems.com (Uri Guttman) Date: Tue, 22 Mar 2011 14:42:35 -0400 Subject: [tpm] use from a local directory In-Reply-To: (Fulko Hew's message of "Tue\, 22 Mar 2011 14\:26\:50 -0400") References: Message-ID: <87r59z3skk.fsf@quad.sysarch.com> >>>>> "FH" == Fulko Hew writes: FH> On Tue, Mar 22, 2011 at 2:22 PM, Fulko Hew wrote: FH> I don't know if I'm doing this right, or in the best manner... FH> And... if I get all this to work... FH> Since a file can contain multiple packages, how can the FH> import discriminate between constants from one package FH> versus the others in the use/require'd file? that can't be done easily with use. it only calls the import method on the class it is given. it also loads the file which matches the class name (with :: converted to /, etc.). why do you have multiple packages in one file? you could break them up and have a wrapper file use them with importing the constants and then exporting all of them to the user. you could have the primary class (same name as the file) import the constants from the other classes and export them. or even with some more powerful modules, you could export the constants directly from their classes. i just smell a design flaw here rather than a problem that needs to be solved in this way. you seem to have painted yourself into a corner with this design. uri -- Uri Guttman ------ uri at stemsystems.com -------- http://www.sysarch.com -- ----- Perl Code Review , Architecture, Development, Training, Support ------ --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com --------- From mattp at cpan.org Tue Mar 22 11:43:02 2011 From: mattp at cpan.org (mattp) Date: Tue, 22 Mar 2011 14:43:02 -0400 Subject: [tpm] use from a local directory In-Reply-To: References: Message-ID: <4D88EDB6.4020109@cpan.org> On 03/22/2011 02:22 PM, Fulko Hew wrote: > I don't know if I'm doing this right, or in the best manner... > > a) I have a compiler that generates Perl classes/source files based on > data you feed it. > b) People then write applications that 'include' those source files. > > Right now I have been using (for example) 'require "module1.pm > ";' in the applications. > Which is great as long as I don't need to have the application run out > of a > non-current-working-directory. > > But now I have a situation where the generated modules have 'use > constant' in them > and I need to have the callers be able to use those constants easily. > > At the moment they need to do $x = Module1::CONSTANT_1(); in order for > it to work. > Something more natural would be $x = Module1::CONSTANT_1; ie. without > the parens. > > To do that I need to use export/import (right?) > And the only way to do that is something like 'use module qw/CONSTANT_1/; > > But then I'm using USE, not REQUIRE, and then the modules need to be > installed > in a standard directory... and the problem then mushrooms. > > Then I find out about 'use lib', but it only knows about explicitly > defined > directories. And 'use lib' isn't any different than didling the @INC > variable > anyway. And there doesn't seem to be an easy way of didling either to > get it > to include the 'invoked' directory (only the current-working-dirctory). > > I figure its easier to ship the executable and its modules in a single > directory, than to ship the executable (where the user can put it anywhere > they want) and then force the user to 'install' the remaining modules. > > > Whats a guy to do? > (Ah, statically compiled executables sure are looking easy right about > now!) > > Comments? > Fulko > > > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm Look into the Readonly and FindBin modules combined with use lib. Cheers, Matt -------------- next part -------------- An HTML attachment was scrubbed... URL: From jbl at jbldata.com Tue Mar 22 12:15:04 2011 From: jbl at jbldata.com (J. Bobby Lopez) Date: Tue, 22 Mar 2011 15:15:04 -0400 Subject: [tpm] use from a local directory In-Reply-To: <4D88EDB6.4020109@cpan.org> References: <4D88EDB6.4020109@cpan.org> Message-ID: +1 for FindBin.. use it all the time. That and CWD should help you accomplish whatever you need to do. On Tue, Mar 22, 2011 at 2:43 PM, mattp wrote: > On 03/22/2011 02:22 PM, Fulko Hew wrote: > > I don't know if I'm doing this right, or in the best manner... > > a) I have a compiler that generates Perl classes/source files based on data > you feed it. > b) People then write applications that 'include' those source files. > > Right now I have been using (for example) 'require "module1.pm";' in the > applications. > Which is great as long as I don't need to have the application run out of a > non-current-working-directory. > > But now I have a situation where the generated modules have 'use constant' > in them > and I need to have the callers be able to use those constants easily. > > At the moment they need to do $x = Module1::CONSTANT_1(); in order for it > to work. > Something more natural would be $x = Module1::CONSTANT_1; ie. without the > parens. > > To do that I need to use export/import (right?) > And the only way to do that is something like 'use module qw/CONSTANT_1/; > > But then I'm using USE, not REQUIRE, and then the modules need to be > installed > in a standard directory... and the problem then mushrooms. > > Then I find out about 'use lib', but it only knows about explicitly defined > directories. And 'use lib' isn't any different than didling the @INC > variable > anyway. And there doesn't seem to be an easy way of didling either to get > it > to include the 'invoked' directory (only the current-working-dirctory). > > I figure its easier to ship the executable and its modules in a single > directory, than to ship the executable (where the user can put it anywhere > they want) and then force the user to 'install' the remaining modules. > > > Whats a guy to do? > (Ah, statically compiled executables sure are looking easy right about > now!) > > Comments? > Fulko > > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.orghttp://mail.pm.org/mailman/listinfo/toronto-pm > > Look into the Readonly and FindBin modules combined with use lib. > > Cheers, > Matt > > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kaidar at ianmartin.com Tue Mar 22 12:15:46 2011 From: Kaidar at ianmartin.com (Ron Kaidar) Date: Tue, 22 Mar 2011 15:15:46 -0400 Subject: [tpm] Perl Developer needed in Oakville / Mississauga .... Ron Kaidar / Ian Martin IT In-Reply-To: References: Message-ID: Hi Everyone, My name is Ron Kaidar and I'm a Senior Account Manager / IT Recruiter for Ian Martin IT in Toronto. I've working for Ian Martin IT for over 5 years now. My client in Oakville is searching for Perl Developers paying between $55,000 -75,000K. Please e-mail me if you're interested. I will be happy to answer any questions you might have. Thanks! Best Regards, Ron Kaidar Senior Account Manager Ian Martin Information Technology Inc. 33 Yonge Street, Suite 902 Toronto, Ontario M5E 1G4 T: (416) 439-6400 x4239 F: (416) 439-6922 C: (416) 262-4054 www.ianmartin.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From ceeshek at gmail.com Wed Mar 23 15:32:23 2011 From: ceeshek at gmail.com (Cees Hek) Date: Thu, 24 Mar 2011 09:32:23 +1100 Subject: [tpm] use from a local directory In-Reply-To: References: <4D88EDB6.4020109@cpan.org> Message-ID: On Wed, Mar 23, 2011 at 6:15 AM, J. Bobby Lopez wrote: > +1 for FindBin.. use it all the time. ?That and CWD should help you > accomplish whatever you need to do. > +1 Also FindBin::libs simplifies looking for a 'lib' directory somewhere up the path of the script and automatically calls the correct 'use lib'. ie if your scripts are in project/bin and your pm files are in project/lib, then all you need in your script files is this: use FindBin::libs; and project/lib will automatically be added to your @INC. Cheers, Cees From mike at stok.ca Fri Mar 25 15:40:13 2011 From: mike at stok.ca (Mike Stok) Date: Fri, 25 Mar 2011 18:40:13 -0400 Subject: [tpm] After-meeting venue for Thursday... Message-ID: I tried to book some space at the Spotted Dick, but they seemed leery of "between 10 and 20 people" that late in the day on a Thursday. There are a number of options, and you'll have to figure out what to do as I'll be listening to Jean-Yves Thibaudet next Thursday evening. The options immediately obvious to me are Descend on the Spotted Dick anyway, it's not like we need contiguous seating, and can split into "reasonable sized" groups. The food and beer are decent and the bar is reasonably quiet. Descend on Burgundys like the good old days. Book somewhere else. If there are strong opinions for this then tell me where and I can organize it. My inclination would be to do the first, as I'm not going to be there it seems reasonable to sound out your collective opinion before doing anything rash like trying to get space elsewhere. Mike -- Mike Stok http://www.stok.ca/~mike/ The "`Stok' disclaimers" apply. -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part URL: From mike at stok.ca Tue Mar 29 09:38:23 2011 From: mike at stok.ca (Mike Stok) Date: Tue, 29 Mar 2011 12:38:23 -0400 Subject: [tpm] March 31 meeting reminder Message-ID: <2DD3019D-CD84-4CF7-A2C2-500B4FF40E8A@stok.ca> Details at http://to.pm.org Date: Thu 31 Mar 2011 18:45 EDT Venue: Global Knowledge (room G 12th floor) Topic: Hands-on with Bricolage CMS: The mature, no-bullshit, built-like-a-tank, web publishing system. Phillip Smith: Hands-on with Bricolage CMS: The mature, no-bullshit, built-like-a-tank, web publishing system. Phillip Smith will give quick (30 min or so) introduction to Bricolage - what it is, what it isn't, its main components, and a couple of scenarios where Bricolage is a good option. There will be time for Q & A and discussion after the talk. Location: 2 Bloor Street West, (usually) 8th or 16th floor. The room number will be announced on the mailing list a few days before the meeting. It will also be left with the security desk in the building (main floor lobby) shortly before the meeting starts (i.e. around 6pm). Time: 6:45 p.m. Directions: This building is on the north-west corner of Bloor and Yonge, accessible by subway from Bloor station. Pay parking is also ample in this area. Security note: The elevators in the building are "locked down" after 5:30pm to people without building access cards. Leading up to the meeting someone will come down to the main floor lobby every few minutes to ferry people upstairs. There will be a number of scheduled trips: 17:30 18:00 18:30 18:45 19:00 After 19:00, you can reach the access-card-carrying guy via a cell phone number that we'll leave with security in the front lobby. The room and floor numbers will be left with security too. If any latecomers call up there will be a final group elevator run at 19:10. After that, access will be ad-hoc; call up from security and somebody will try to come down and let you up. -- Mike Stok http://www.stok.ca/~mike/ The "`Stok' disclaimers" apply. -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part URL: From jbl at jbldata.com Tue Mar 29 09:44:04 2011 From: jbl at jbldata.com (J. Bobby Lopez) Date: Tue, 29 Mar 2011 12:44:04 -0400 Subject: [tpm] Playing with Dancer (beginner assistance required) Message-ID: So I started playing with Dancer, and am trying to figure out how to enable logging. I've seen the Dancer Cookbook, and saw the Dancer::Config stuff: Dancer::Config::setting('appdir',$appdir); Dancer::Config::load(); And I added the 'logger' and 'log' items to the config.yml file, but when I try to use a simple debug statement, such as: debug "hey it's me"; It doesn't log to the console or any log file. No log file is created in the appdir/. What am I missing? Thanks, -Bobby -------------- next part -------------- An HTML attachment was scrubbed... URL: From dave.s.doyle at gmail.com Tue Mar 29 09:51:18 2011 From: dave.s.doyle at gmail.com (Dave Doyle) Date: Tue, 29 Mar 2011 12:51:18 -0400 Subject: [tpm] Playing with Dancer (beginner assistance required) In-Reply-To: References: Message-ID: 1) How are you running the app? Just perl bin/app.pl? 2) Can you post the contents of config.yml and environments/development.yml? ( less passwordy-bits of course) Thanks, D -- dave.s.doyle at gmail.com On Tue, Mar 29, 2011 at 12:44 PM, J. Bobby Lopez wrote: > So I started playing with Dancer, and am trying to figure out how to enable > logging. > > I've seen the Dancer Cookbook, and saw the Dancer::Config stuff: > > Dancer::Config::setting('appdir',$appdir); > Dancer::Config::load(); > > And I added the 'logger' and 'log' items to the config.yml file, but when I > try to use a simple debug statement, such as: > > debug "hey it's me"; > > It doesn't log to the console or any log file. No log file is created in > the appdir/. > > What am I missing? > > Thanks, > -Bobby > > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jbl at jbldata.com Tue Mar 29 10:01:13 2011 From: jbl at jbldata.com (J. Bobby Lopez) Date: Tue, 29 Mar 2011 13:01:13 -0400 Subject: [tpm] Playing with Dancer (beginner assistance required) In-Reply-To: References: Message-ID: Hey Dave, I just added two lines to the default config.yml: logger: 'file' log: 'core' I'm running the app via ./bin/app.pl, yes. Didn't modify development.yml, but see that it is the following: logger: "console" log: "core" warnings: 1 show_errors: 1 auto_reload: 0 On Tue, Mar 29, 2011 at 12:51 PM, Dave Doyle wrote: > 1) How are you running the app? Just perl bin/app.pl? > 2) Can you post the contents of config.yml and > environments/development.yml? ( less passwordy-bits of course) > > Thanks, > D > -- > dave.s.doyle at gmail.com > > > On Tue, Mar 29, 2011 at 12:44 PM, J. Bobby Lopez wrote: > >> So I started playing with Dancer, and am trying to figure out how to >> enable logging. >> >> I've seen the Dancer Cookbook, and saw the Dancer::Config stuff: >> >> Dancer::Config::setting('appdir',$appdir); >> Dancer::Config::load(); >> >> And I added the 'logger' and 'log' items to the config.yml file, but when >> I try to use a simple debug statement, such as: >> >> debug "hey it's me"; >> >> It doesn't log to the console or any log file. No log file is created in >> the appdir/. >> >> What am I missing? >> >> Thanks, >> -Bobby >> >> _______________________________________________ >> toronto-pm mailing list >> toronto-pm at pm.org >> http://mail.pm.org/mailman/listinfo/toronto-pm >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dave.s.doyle at gmail.com Tue Mar 29 10:07:58 2011 From: dave.s.doyle at gmail.com (Dave Doyle) Date: Tue, 29 Mar 2011 13:07:58 -0400 Subject: [tpm] Playing with Dancer (beginner assistance required) In-Reply-To: References: Message-ID: Okay, stuff in the development.yaml will override stuff in config.yml (the intent is so you can have difference loggers, log levels, etc for production/dev) so it's going to change the logger to a console logger so you should see it directly in the output (not sure why you don't). You can try yanking the log stuff out of config.yml and change the development.yml to logger to "file". It should then log to log/development.log. -- dave.s.doyle at gmail.com On Tue, Mar 29, 2011 at 1:01 PM, J. Bobby Lopez wrote: > Hey Dave, > > I just added two lines to the default config.yml: > logger: 'file' > log: 'core' > > I'm running the app via ./bin/app.pl, yes. > > Didn't modify development.yml, but see that it is the following: > > logger: "console" > log: "core" > warnings: 1 > show_errors: 1 > auto_reload: 0 > > On Tue, Mar 29, 2011 at 12:51 PM, Dave Doyle wrote: > >> 1) How are you running the app? Just perl bin/app.pl? >> 2) Can you post the contents of config.yml and >> environments/development.yml? ( less passwordy-bits of course) >> >> Thanks, >> D >> -- >> dave.s.doyle at gmail.com >> >> >> On Tue, Mar 29, 2011 at 12:44 PM, J. Bobby Lopez wrote: >> >>> So I started playing with Dancer, and am trying to figure out how to >>> enable logging. >>> >>> I've seen the Dancer Cookbook, and saw the Dancer::Config stuff: >>> >>> Dancer::Config::setting('appdir',$appdir); >>> Dancer::Config::load(); >>> >>> And I added the 'logger' and 'log' items to the config.yml file, but when >>> I try to use a simple debug statement, such as: >>> >>> debug "hey it's me"; >>> >>> It doesn't log to the console or any log file. No log file is created in >>> the appdir/. >>> >>> What am I missing? >>> >>> Thanks, >>> -Bobby >>> >>> _______________________________________________ >>> toronto-pm mailing list >>> toronto-pm at pm.org >>> http://mail.pm.org/mailman/listinfo/toronto-pm >>> >>> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jbl at jbldata.com Tue Mar 29 10:10:08 2011 From: jbl at jbldata.com (J. Bobby Lopez) Date: Tue, 29 Mar 2011 13:10:08 -0400 Subject: [tpm] Playing with Dancer (beginner assistance required) In-Reply-To: References: Message-ID: Understood.. I thought it was the other way around (config.yml overrides development.yml). Logging works now, thanks! On Tue, Mar 29, 2011 at 1:07 PM, Dave Doyle wrote: > Okay, stuff in the development.yaml will override stuff in config.yml (the > intent is so you can have difference loggers, log levels, etc for > production/dev) so it's going to change the logger to a console logger so > you should see it directly in the output (not sure why you don't). You can > try yanking the log stuff out of config.yml and change the development.yml > to logger to "file". It should then log to log/development.log. > -- > dave.s.doyle at gmail.com > > > On Tue, Mar 29, 2011 at 1:01 PM, J. Bobby Lopez wrote: > >> Hey Dave, >> >> I just added two lines to the default config.yml: >> logger: 'file' >> log: 'core' >> >> I'm running the app via ./bin/app.pl, yes. >> >> Didn't modify development.yml, but see that it is the following: >> >> logger: "console" >> log: "core" >> warnings: 1 >> show_errors: 1 >> auto_reload: 0 >> >> On Tue, Mar 29, 2011 at 12:51 PM, Dave Doyle wrote: >> >>> 1) How are you running the app? Just perl bin/app.pl? >>> 2) Can you post the contents of config.yml and >>> environments/development.yml? ( less passwordy-bits of course) >>> >>> Thanks, >>> D >>> -- >>> dave.s.doyle at gmail.com >>> >>> >>> On Tue, Mar 29, 2011 at 12:44 PM, J. Bobby Lopez wrote: >>> >>>> So I started playing with Dancer, and am trying to figure out how to >>>> enable logging. >>>> >>>> I've seen the Dancer Cookbook, and saw the Dancer::Config stuff: >>>> >>>> Dancer::Config::setting('appdir',$appdir); >>>> Dancer::Config::load(); >>>> >>>> And I added the 'logger' and 'log' items to the config.yml file, but >>>> when I try to use a simple debug statement, such as: >>>> >>>> debug "hey it's me"; >>>> >>>> It doesn't log to the console or any log file. No log file is created >>>> in the appdir/. >>>> >>>> What am I missing? >>>> >>>> Thanks, >>>> -Bobby >>>> >>>> _______________________________________________ >>>> toronto-pm mailing list >>>> toronto-pm at pm.org >>>> http://mail.pm.org/mailman/listinfo/toronto-pm >>>> >>>> >>> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: