From madcityzen at gmail.com Mon Sep 10 19:33:42 2012 From: madcityzen at gmail.com (Doug Bell) Date: Mon, 10 Sep 2012 21:33:42 -0500 Subject: [Chicago-talk] Reminder: Project Night - Thursday Sept 10, 6:30p Message-ID: <05EE4D4D-DBA1-4625-AAA6-9621347DCD80@gmail.com> This is a friendly reminder that our first project night is this Thursday, September 10 at 6:30pm at 540 W Madison in the 9th floor conference rooms. This get-together will be Bring Your Own Beverage, though if anything from the last meeting has survived in the office fridge (soda probably, beer probably not), that will be available. RSVP on the meetup: http://www.meetup.com/Windy-City-Perl-mongers-Meetup/events/79680292/ See you there! Doug Bell madcityzen at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From shawn.c.carroll at gmail.com Tue Sep 11 11:33:14 2012 From: shawn.c.carroll at gmail.com (Shawn Carroll) Date: Tue, 11 Sep 2012 13:33:14 -0500 Subject: [Chicago-talk] Odd HoH bug/problem Message-ID: Let me preface this by saying that I have not been able to reproduce this problem in a smaller program and I understand that this makes it less useful for identifying the root cause. In my program I create a HoHoH and need to step through in a final sub. As I've done many times in the past I use a while block and use each to assign the key & value to loop variables. while( my ($id, $types) = each %data ) { say "$id => $types"; while ( my ($type, $data) = each %{ $types }) { my $callPuts = $strikes->{$callPut}; # say "$instrumentID -> $callPut"; shawn.c.carroll at gmail.com Perl Programmer Soccer Referee From shawn.c.carroll at gmail.com Tue Sep 11 11:36:49 2012 From: shawn.c.carroll at gmail.com (Shawn Carroll) Date: Tue, 11 Sep 2012 13:36:49 -0500 Subject: [Chicago-talk] Odd HoH bug/problem In-Reply-To: References: Message-ID: I hit send to soon... On Tue, Sep 11, 2012 at 1:33 PM, Shawn Carroll wrote: > Let me preface this by saying that I have not been able to reproduce > this problem in a smaller program and I understand that this makes it > less useful for identifying the root cause. > > In my program I create a HoHoH and need to step through in a final > sub. As I've done many times in the past I use a while block and use > each to assign the key & value to loop variables. > > while( my ($id, $types) = each %data ) > { > say "$id => $types"; > while ( my ($type, $data) = each %{ $types }) > { say $type # processData } } The first say confirms that every $types is a hash but the second while loop doesn't process every $types. If I replace the second while with a foreach my $type (keys %{$types}) loop everything works as expected. Am I missing something here? I am confused. From merlyn at stonehenge.com Tue Sep 11 11:47:46 2012 From: merlyn at stonehenge.com (Randal L. Schwartz) Date: Tue, 11 Sep 2012 11:47:46 -0700 Subject: [Chicago-talk] Odd HoH bug/problem In-Reply-To: (Shawn Carroll's message of "Tue, 11 Sep 2012 13:33:14 -0500") References: Message-ID: <86liggpfal.fsf@red.stonehenge.com> >>>>> "Shawn" == Shawn Carroll writes: Shawn> Let me preface this by saying that I have not been able to reproduce Shawn> this problem in a smaller program and I understand that this makes it Shawn> less useful for identifying the root cause. Shawn> In my program I create a HoHoH and need to step through in a final Shawn> sub. As I've done many times in the past I use a while block and use Shawn> each to assign the key & value to loop variables. Shawn> while( my ($id, $types) = each %data ) Shawn> { Shawn> say "$id => $types"; Shawn> while ( my ($type, $data) = each %{ $types }) Shawn> { Shawn> my $callPuts = $strikes->{$callPut}; Shawn> # say "$instrumentID -> $callPut"; Is there a question? Hit send too quickly? -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc. See http://methodsandmessages.posterous.com/ for Smalltalk discussion From merlyn at stonehenge.com Tue Sep 11 11:53:19 2012 From: merlyn at stonehenge.com (Randal L. Schwartz) Date: Tue, 11 Sep 2012 11:53:19 -0700 Subject: [Chicago-talk] Odd HoH bug/problem In-Reply-To: (Shawn Carroll's message of "Tue, 11 Sep 2012 13:36:49 -0500") References: Message-ID: <86har4pf1c.fsf@red.stonehenge.com> >>>>> "Shawn" == Shawn Carroll writes: Shawn> I hit send to soon... Shawn> On Tue, Sep 11, 2012 at 1:33 PM, Shawn Carroll Shawn> wrote: >> Let me preface this by saying that I have not been able to reproduce >> this problem in a smaller program and I understand that this makes it >> less useful for identifying the root cause. >> >> In my program I create a HoHoH and need to step through in a final >> sub. As I've done many times in the past I use a while block and use >> each to assign the key & value to loop variables. >> >> while( my ($id, $types) = each %data ) >> { >> say "$id => $types"; >> while ( my ($type, $data) = each %{ $types }) >> { Shawn> say $type Shawn> # processData Shawn> } Shawn> } Shawn> The first say confirms that every $types is a hash but the second Shawn> while loop doesn't process every $types. If I replace the second Shawn> while with a foreach my $type (keys %{$types}) loop everything works Shawn> as expected. Are you adding or deleting things from %$types during the each iteration? If so, that can mess up your day. Is anything else also walking the hash (like something calling keys, values, or each as well)? There's only one each-style iterator per hash. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc. See http://methodsandmessages.posterous.com/ for Smalltalk discussion From shawn.c.carroll at gmail.com Tue Sep 11 12:10:38 2012 From: shawn.c.carroll at gmail.com (Shawn Carroll) Date: Tue, 11 Sep 2012 14:10:38 -0500 Subject: [Chicago-talk] Odd HoH bug/problem In-Reply-To: <86har4pf1c.fsf@red.stonehenge.com> References: <86har4pf1c.fsf@red.stonehenge.com> Message-ID: On Tue, Sep 11, 2012 at 1:53 PM, Randal L. Schwartz wrote: >>>>>> "Shawn" == Shawn Carroll writes: > > Shawn> I hit send to soon... > Shawn> On Tue, Sep 11, 2012 at 1:33 PM, Shawn Carroll > Shawn> wrote: >>> Let me preface this by saying that I have not been able to reproduce >>> this problem in a smaller program and I understand that this makes it >>> less useful for identifying the root cause. >>> >>> In my program I create a HoHoH and need to step through in a final >>> sub. As I've done many times in the past I use a while block and use >>> each to assign the key & value to loop variables. >>> >>> while( my ($id, $types) = each %data ) >>> { >>> say "$id => $types"; >>> while ( my ($type, $data) = each %{ $types }) >>> { > Shawn> say $type > Shawn> # processData > Shawn> } > Shawn> } > > Shawn> The first say confirms that every $types is a hash but the second > Shawn> while loop doesn't process every $types. If I replace the second > Shawn> while with a foreach my $type (keys %{$types}) loop everything works > Shawn> as expected. > > Are you adding or deleting things from %$types during the each > iteration? If so, that can mess up your day. > > Is anything else also walking the hash (like something calling keys, > values, or each as well)? There's only one each-style iterator per > hash. > > -- > Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 > > Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc. > See http://methodsandmessages.posterous.com/ for Smalltalk discussion No adding or deleting from %$types nor is anything else walking either hash. While I was debugging this I had say Dumper statements, to confirm the data I was expecting was there, to dump the contents of %$types before the while inner loop and everything would work as expected. W/o it I wouldn't get all my data. The inputs all stayed the same between each run and I am not doing anything funky w/ the data, just pulling out what I need for output. I even confirmed after the outer loop that the data I wanted was still there. I am happy I have a fix, but I'd love to understand what I did wrong. Tonight if I have time I will see if I can reproduce on a smaller set that I can share w/ the world but I'm not holding out hope. From merlyn at stonehenge.com Tue Sep 11 12:17:13 2012 From: merlyn at stonehenge.com (Randal L. Schwartz) Date: Tue, 11 Sep 2012 12:17:13 -0700 Subject: [Chicago-talk] Odd HoH bug/problem In-Reply-To: (Shawn Carroll's message of "Tue, 11 Sep 2012 14:10:38 -0500") References: <86har4pf1c.fsf@red.stonehenge.com> Message-ID: <86bohcpdxi.fsf@red.stonehenge.com> >>>>> "Shawn" == Shawn Carroll writes: Shawn> While I was debugging this I had say Dumper statements, to confirm the Shawn> data I was expecting was there, to dump the contents of %$types before Shawn> the while inner loop and everything would work as expected. W/o it I Shawn> wouldn't get all my data. The inputs all stayed the same between each Shawn> run and I am not doing anything funky w/ the data, just pulling out Shawn> what I need for output. I even confirmed after the outer loop that Shawn> the data I wanted was still there. Dumper is walking your hashes, resetting your iterators. There is still something you're not revealing, because I'm puzzled. I suspect something *before* these loops is leaving the iterators mid-stride, which is why Dumper "fixes" it. As a test, try this: my @dummy = keys %outer; while (my($k, $v) = each %outer) { my @other_dummy = keys %$v; while (my($k2, $v2) = each %$v) { .. } } If calling keys like this fixes it, then you have something before the loop that is leaving the iterator mid-stride. It's one of the reasons I rarely use each() any more. That mid-stride iterator has bit me too many times. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc. See http://methodsandmessages.posterous.com/ for Smalltalk discussion From shawn.c.carroll at gmail.com Tue Sep 11 12:58:07 2012 From: shawn.c.carroll at gmail.com (Shawn Carroll) Date: Tue, 11 Sep 2012 14:58:07 -0500 Subject: [Chicago-talk] Odd HoH bug/problem In-Reply-To: <86bohcpdxi.fsf@red.stonehenge.com> References: <86har4pf1c.fsf@red.stonehenge.com> <86bohcpdxi.fsf@red.stonehenge.com> Message-ID: On Tue, Sep 11, 2012 at 2:17 PM, Randal L. Schwartz wrote: >>>>>> "Shawn" == Shawn Carroll writes: > > Shawn> While I was debugging this I had say Dumper statements, to confirm the > Shawn> data I was expecting was there, to dump the contents of %$types before > Shawn> the while inner loop and everything would work as expected. W/o it I > Shawn> wouldn't get all my data. The inputs all stayed the same between each > Shawn> run and I am not doing anything funky w/ the data, just pulling out > Shawn> what I need for output. I even confirmed after the outer loop that > Shawn> the data I wanted was still there. > > Dumper is walking your hashes, resetting your iterators. > > There is still something you're not revealing, because I'm puzzled. > > I suspect something *before* these loops is leaving the iterators > mid-stride, which is why Dumper "fixes" it. As a test, try this: > > my @dummy = keys %outer; > while (my($k, $v) = each %outer) { > my @other_dummy = keys %$v; > while (my($k2, $v2) = each %$v) { > .. > } > } > > If calling keys like this fixes it, then you have something before the > loop that is leaving the iterator mid-stride. > > It's one of the reasons I rarely use each() any more. That mid-stride > iterator has bit me too many times. > That did the trick. I don't see anything in my processing that would make it leave the iterator but oh well. Thank you for the help, sir. --Shawn From madcityzen at gmail.com Tue Sep 25 22:08:00 2012 From: madcityzen at gmail.com (Doug Bell) Date: Wed, 26 Sep 2012 00:08:00 -0500 Subject: [Chicago-talk] Meeting: App::Services - Thurs, Sept 27, 6:30pm Message-ID: Hello everybody! We have a presentation this Thursday, September 27, starting at 6:30pm. Sean Blanton will be given a talk on a module he's been developing called App::Services. More details and RSVP on the meetup at http://www.meetup.com/Windy-City-Perl-mongers-Meetup/events/81409372/ Pizza and beverages will be provided. Doug Bell madcityzen at gmail.com From madcityzen at gmail.com Thu Sep 27 22:39:32 2012 From: madcityzen at gmail.com (Doug Bell) Date: Fri, 28 Sep 2012 00:39:32 -0500 Subject: [Chicago-talk] Upcoming Project Night Message-ID: First I want to thank Sean for giving a presentation, and everyone who came out. There was some excellent side-discussion on logging and how to build CPAN dists, and I learned that the Salt Stack exists, which is an interesting project. We have a project night coming up in two weeks. Does someone have a project they want to get some assistance on (I know I've got a couple)? Would people be interested in working on some CPAN module bug lists? Should we stick with App-Prima-REPL and get it polished up more? Gabor Szabo also recently announced the Perl Maven Competition (http://perlmaven.com), which I think would be great for us to participate in. It's a short, 48-hour code marathon with the goal of producing an end-user product. It's running December 15-16, so we have plenty of time to prepare ourselves. We need 4 people total. Doug Bell madcityzen at gmail.com From me at heyjay.com Fri Sep 28 07:41:55 2012 From: me at heyjay.com (Jay Strauss) Date: Fri, 28 Sep 2012 09:41:55 -0500 Subject: [Chicago-talk] Question about removing '’' Message-ID: Hi, I'm scraping a web page (code below) using HTML::TreeBuilder. I'm trying to get the info between the , but embedded in some of the values is a ’ like: Today’s Volume What I want to do is remove the "’" or convert to a single quote, within the HTML::TreeBuilder object, figuring that's probably a more reliable approach. What I'm currently doing is just converting to text and doing a regex my $text = $cell->as_text; $text =~ s/Today.s Volume/Today's Volume/; Any suggestions on how to do this? Thanks Jay use strict; use WWW::Mechanize; use HTML::TreeBuilder 5 -weak; use Data::Dumper; my $mech = retrieve_graham_quote("DELL"); my $info = parse_page($mech); sub retrieve_graham_quote { my $ticker = shift; my $base_url = 'http://www.grahaminvestor.com/quotes/?ticker='; my $mech = WWW::Mechanize->new(); $mech->get( $base_url.$ticker ); return $mech; } sub parse_page { my $mech = shift; my $tree = HTML::TreeBuilder->new; $tree->parse($mech->content()); my $table = $tree->look_down('_tag','table'); foreach my $row ($table->look_down('_tag', 'tr')) { foreach my $cell ($row->look_down('_tag', 'td')) { my $text = $cell->as_text; $text =~ s/Today.s Volume/Today's Volume/; print "-", $text,"\n"; print "-", $cell->as_HTML,"\n"; } } } -------------- next part -------------- An HTML attachment was scrubbed... URL: From madcityzen at gmail.com Fri Sep 28 07:53:22 2012 From: madcityzen at gmail.com (Doug Bell) Date: Fri, 28 Sep 2012 09:53:22 -0500 Subject: [Chicago-talk] Question about removing '’' In-Reply-To: References: Message-ID: <496E6DC6-84E0-4036-A24B-F6B6CCC4898E@gmail.com> On Sep 28, 2012, at 9:41 AM, Jay Strauss wrote: > Hi, > > I'm scraping a web page (code below) using HTML::TreeBuilder. I'm trying to get the info between the , but embedded in some of the values is a ’ like: > > Today’s Volume > > What I want to do is remove the "’" or convert to a single quote, within the HTML::TreeBuilder object, figuring that's probably a more reliable approach. That &foo; construct is an "HTML Entity", which the HTML::Entities module can decode for you, like: use HTML::Entities qw( decode_entities ); print decode_entities( 'That’s all folks!' ); That entity is specifically a right-angled single quote, so if that exact character is not what you want, then you could use your regular expression to change it to a straight single quote (the ' character). Doug Bell madcityzen at gmail.com From me at heyjay.com Fri Sep 28 08:33:20 2012 From: me at heyjay.com (Jay Strauss) Date: Fri, 28 Sep 2012 10:33:20 -0500 Subject: [Chicago-talk] Question about removing '’' In-Reply-To: <496E6DC6-84E0-4036-A24B-F6B6CCC4898E@gmail.com> References: <496E6DC6-84E0-4036-A24B-F6B6CCC4898E@gmail.com> Message-ID: Thanks Doug. I'm not sure how that's different than what I'm doing? In that I want to actually change the contents within the HTML::TreeObject, and not just decode (or regex) the output of $cell->as_HTML. Maybe I missed something Thanks Jay On Fri, Sep 28, 2012 at 9:53 AM, Doug Bell wrote: > > On Sep 28, 2012, at 9:41 AM, Jay Strauss wrote: > > > Hi, > > > > I'm scraping a web page (code below) using HTML::TreeBuilder. I'm > trying to get the info between the , but embedded in some of the > values is a ’ like: > > > > Today’s Volume > > > > What I want to do is remove the "’" or convert to a single quote, > within the HTML::TreeBuilder object, figuring that's probably a more > reliable approach. > > That &foo; construct is an "HTML Entity", which the HTML::Entities module > can decode for you, like: > > use HTML::Entities qw( decode_entities ); > print decode_entities( 'That’s all folks!' ); > > That entity is specifically a right-angled single quote, so if that exact > character is not what you want, then you could use your regular expression > to change it to a straight single quote (the ' character). > > Doug Bell > madcityzen at gmail.com > > > > _______________________________________________ > Chicago-talk mailing list > Chicago-talk at pm.org > http://mail.pm.org/mailman/listinfo/chicago-talk > -------------- next part -------------- An HTML attachment was scrubbed... URL: From me at heyjay.com Fri Sep 28 08:33:57 2012 From: me at heyjay.com (Jay Strauss) Date: Fri, 28 Sep 2012 10:33:57 -0500 Subject: [Chicago-talk] Question about removing '’' In-Reply-To: References: <496E6DC6-84E0-4036-A24B-F6B6CCC4898E@gmail.com> Message-ID: opps HTML::TreeBuilder object On Fri, Sep 28, 2012 at 10:33 AM, Jay Strauss wrote: > Thanks Doug. I'm not sure how that's different than what I'm doing? > > In that I want to actually change the contents within the > HTML::TreeObject, and not just decode (or regex) the output of > $cell->as_HTML. > > Maybe I missed something > > Thanks > Jay > > > On Fri, Sep 28, 2012 at 9:53 AM, Doug Bell wrote: > >> >> On Sep 28, 2012, at 9:41 AM, Jay Strauss wrote: >> >> > Hi, >> > >> > I'm scraping a web page (code below) using HTML::TreeBuilder. I'm >> trying to get the info between the , but embedded in some of the >> values is a ’ like: >> > >> > Today’s Volume >> > >> > What I want to do is remove the "’" or convert to a single quote, >> within the HTML::TreeBuilder object, figuring that's probably a more >> reliable approach. >> >> That &foo; construct is an "HTML Entity", which the HTML::Entities module >> can decode for you, like: >> >> use HTML::Entities qw( decode_entities ); >> print decode_entities( 'That’s all folks!' ); >> >> That entity is specifically a right-angled single quote, so if that exact >> character is not what you want, then you could use your regular expression >> to change it to a straight single quote (the ' character). >> >> Doug Bell >> madcityzen at gmail.com >> >> >> >> _______________________________________________ >> Chicago-talk mailing list >> Chicago-talk at pm.org >> http://mail.pm.org/mailman/listinfo/chicago-talk >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: