From jay at jays.net Sun Jul 1 11:04:11 2007 From: jay at jays.net (Jay Hannah) Date: Sun, 1 Jul 2007 13:04:11 -0500 Subject: [Omaha.pm] bug hunt Message-ID: Code: my $w1=$original_when; my $w1=~s/[\s:-]//; Jay asserts: That can't be right. The second line uses "my" again, which wipes out the assignment from the first line. So $w1 will always be undef, and those two lines of code could be reduced to a single line: "my $w1;". Doh! :) j From andy at petdance.com Sun Jul 1 18:07:58 2007 From: andy at petdance.com (Andy Lester) Date: Sun, 1 Jul 2007 20:07:58 -0500 Subject: [Omaha.pm] bug hunt In-Reply-To: References: Message-ID: <8140359B-8516-48E4-B803-AEA5EB9FB217@petdance.com> On Jul 1, 2007, at 1:04 PM, Jay Hannah wrote: > my $w1=$original_when; > my $w1=~s/[\s:-]//; > > > > Jay asserts: > > That can't be right. The second line uses "my" again, which wipes out > the assignment from the first line. If the original code had been run under "use warnings", it would have put out this message: "my" variable $w1 masks earlier declaration in same scope at foo line 2. Use of uninitialized value in substitution (s///) at foo line 2. -- Andy Lester => andy at petdance.com => www.petdance.com => AIM:petdance From trey-b at cox.net Sun Jul 1 19:29:41 2007 From: trey-b at cox.net (trey-b at cox.net) Date: Sun, 1 Jul 2007 22:29:41 -0400 Subject: [Omaha.pm] bug hunt Message-ID: <28106536.1183343381062.JavaMail.root@eastrmwml12> ---- Andy Lester wrote: > > On Jul 1, 2007, at 1:04 PM, Jay Hannah wrote: > > > my $w1=$original_when; > > my $w1=~s/[\s:-]//; > > > > > > > > Jay asserts: > > > > That can't be right. The second line uses "my" again, which wipes out > > the assignment from the first line. > > If the original code had been run under "use warnings", it would have > put out this message: > > > "my" variable $w1 masks earlier declaration in same scope at foo line 2. > Use of uninitialized value in substitution (s///) at foo line 2. > > -- > Andy Lester => andy at petdance.com => www.petdance.com => AIM:petdance > > > > > _______________________________________________ > Omaha-pm mailing list > Omaha-pm at pm.org > http://mail.pm.org/mailman/listinfo/omaha-pm It looks like something I would do when in a hurry. yyp From jhannah at omnihotels.com Tue Jul 3 08:54:08 2007 From: jhannah at omnihotels.com (Jay Hannah) Date: Tue, 03 Jul 2007 10:54:08 -0500 Subject: [Omaha.pm] POD Message-ID: My $0.02 / FYI / ignore me -- In blocks like this ------ =head2 set_request gets RequestAvail object =cut ------- You don't want to indent "normal text". Leave the indention off and POD viewers re-wrap paragraphs to fit the width of the viewers screen. When you indent in POD you're telling the viewer to never line-wrap, which is good for code samples but bad for normal descriptive text. And "podchecker" is a handy tool, below. Thanks, J jhannah at razorbill:~/M/omares/Complex> podchecker L_Reservation.pm *** ERROR: Spurious text after =cut at line 175 in file L_Reservation.pm *** ERROR: Spurious text after =cut at line 182 in file L_Reservation.pm *** WARNING: line containing nothing but whitespace in paragraph at line 263 in file L_Reservation.pm *** ERROR: empty =head2 at line 545 in file L_Reservation.pm *** WARNING: line containing nothing but whitespace in paragraph at line 827 in file L_Reservation.pm L_Reservation.pm has 3 pod syntax errors. From Jay at RebootTheUser.com Thu Jul 5 10:10:51 2007 From: Jay at RebootTheUser.com (Jay Swackhamer) Date: Thu, 05 Jul 2007 12:10:51 -0500 Subject: [Omaha.pm] New site/organization - Please disregard if you are not interested in motor-vehicles. In-Reply-To: <28106536.1183343381062.JavaMail.root@eastrmwml12> References: <28106536.1183343381062.JavaMail.root@eastrmwml12> Message-ID: <20070705121051.hddlbma40o8s4cgk@webmail.hotr.com> Please disregard if you are not interested in motor-vehicles. Read on if you are! I am launching a couple of new sites www.MoGeek.org and www.MoGeek.net for information and forums for Motor-Head/Geeks. So if you are interested in Cars/Trucks/Motorcycles/Computers in any combination, these sites will be for you. If you would like to join/contribute, all are welcome. Preliminary meetings will be on the 2nd saturday of the month, unless the group votes for a different day. This group will be for people to get together and work on vehicles, maybe someones project one week, then another members on another week. Computer/Car integration will be discussed. I would like to grow it into an organization that participates in events/cruises/poker runs/test & tune/etc.... Contact me off list, if interested. -- Jay Swackhamer Reboot The User 13416 A Street Omaha, NE 68144 402-933-6449 Hours: 6pm-11pm Tues-Fri, 4pm-9pm Sat. http://www.reboottheuser.com http://www.cafepress.com/rtu From jay at jays.net Fri Jul 6 09:11:46 2007 From: jay at jays.net (Jay Hannah) Date: Fri, 6 Jul 2007 11:11:46 -0500 Subject: [Omaha.pm] Fwd: July 10 Meeting - Jay Hannah on Perl and Bionformatics References: <20070706024124.20471.qmail@server271.com> Message-ID: <413D7EA7-CC73-4DB8-B798-9503BC91BAA0@jays.net> Reminder: This months Perl Mongers meeting has been merged into the Dynamic Language Users Group. See you Tuesday! j http://omaha.pm.org From: "Blaine Buxton" Date: July 5, 2007 9:41:24 PM CDT To: "dynamic_omaha at blainebuxton.com" Subject: [dynamic_omaha] July 10 Meeting - Jay Hannah on Perl and Bionformatics Reply-To: "Blaine Buxton" Get out the thinking caps because Jay Hannah is coming to speak about how to mix Bioinformatics and Perl together perfectly. It's going to be one night that you will not forget. Jay has a love for both and he will make you a believer that Perl is more than just another scripting language. We are sponsored this week by none other than Bass. They will bring the food and beverages. Intelligent conversation, great food, excellent company, and it's all free. Come and see that the fuss is us. TopicBioinformatics and Perl SpeakerJay Hannah TimeJuly 10, 7-9pm LocationUNO's Peter Kiewit Institute (PKI) building 1110 South 67th Street Omaha, NE -- Blaine Buxton Simplicity Synthesist http://blog.blainebuxton.com From jay at jays.net Sat Jul 14 05:16:50 2007 From: jay at jays.net (Jay Hannah) Date: Sat, 14 Jul 2007 07:16:50 -0500 Subject: [Omaha.pm] Fwd: [omaha] better than pyexpect? References: <83DFE3C2-9E28-4E22-A8A7-22558DF965BA@jays.net> Message-ID: <9E8986DF-439F-42BE-B7C2-1DF93E483965@jays.net> On Jun 28, 2007, at 9:48 PM, Jeff Hinrichs - DM&T wrote: > At our last gathering Eli and others were talking about the Expect > utility and the pyexpect bindings. While I was going through my feeds > tonight I came across a story, "Exscript Scripting Language - > Automating Telnet" http://debain.org/?p=196 > > The author talks about using pyexpect, having some difficulties, then > moving to perl and then eventually leaving perl and writing their own > python module. It has a number of features including threading. > http://code.google.com/p/exscript/ > > Anyone heard of this or used it? I've used Perl's Expect.pm on several occasions: http://search.cpan.org/~rgiersig/Expect-1.20/Expect.pod Here's a little example I wrote: http://omaha.pm.org/presentations/pscrawl_pl.txt Thanks for hosting the meeting the week! Cheers, j From jay at jays.net Mon Jul 16 10:41:23 2007 From: jay at jays.net (Jay Hannah) Date: Mon, 16 Jul 2007 13:41:23 -0400 (EDT) Subject: [Omaha.pm] grep -P Message-ID: -laugh- I didn't know GNU grep has a command line switch for "Perl regular expressions"... Grab all the lines from myfile.txt that start with chr3 and then a tab: grep -P "^chr3\t" filename.txt Or, you could just use Perl: perl -ne 'print if (/^chr3\t/)' filename.txt :) j From andy at petdance.com Mon Jul 16 11:09:52 2007 From: andy at petdance.com (Andy Lester) Date: Mon, 16 Jul 2007 13:09:52 -0500 Subject: [Omaha.pm] grep -P In-Reply-To: References: Message-ID: <874C62ED-8078-4EFC-A4B1-A4494AC1BF60@petdance.com> On Jul 16, 2007, at 12:41 PM, Jay Hannah wrote: > -laugh- > > I didn't know GNU grep has a command line switch for "Perl regular > expressions"... > > Grab all the lines from myfile.txt that start with chr3 and then a > tab: > grep -P "^chr3\t" filename.txt > > Or, you could just use Perl: > perl -ne 'print if (/^chr3\t/)' filename.txt Or you could use ack: http://petdance.com/ack/ -- Andy Lester => andy at petdance.com => www.petdance.com => AIM:petdance From dan at linder.org Mon Jul 16 20:58:28 2007 From: dan at linder.org (Daniel Linder) Date: Mon, 16 Jul 2007 22:58:28 -0500 (CDT) Subject: [Omaha.pm] Active bandwidth monitoring Message-ID: <4415.70.165.110.36.1184644708.squirrel@webmail.linder.org> I'm trying to pro-actively monitor the "real world" speed that I'm getting with my @Work connection. Unfortunately Googling for "bandwidth monitoring" brings up programs that will monitor traffic already going through the machines interfaces, not actively probing a set of remote sites. In a perfect world the application would have a list sites to download a test file from, compute the average, and store the details in a RRD file for later review. As another idea, the "list of sites" could be a set of "random Google/Yahoo/MSN/etc links" -- a better "real world" test? Questions: 1: Has anyone run across a tool like this that is free and will run on Linux? 2: If I stared to write something like this, has anyone got some Perl code to grab random URLs from a search engine? Dan - - - - "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -- Ed Howdershelt (Author) "I do not fear computers, I fear the lack of them." -- Isaac Asimov (Author) From jay at jays.net Tue Jul 17 06:47:51 2007 From: jay at jays.net (Jay Hannah) Date: Tue, 17 Jul 2007 08:47:51 -0500 Subject: [Omaha.pm] Active bandwidth monitoring In-Reply-To: <4415.70.165.110.36.1184644708.squirrel@webmail.linder.org> References: <4415.70.165.110.36.1184644708.squirrel@webmail.linder.org> Message-ID: <46AAF41F-AED3-4988-B686-90F81759E3F6@jays.net> On Jul 16, 2007, at 10:58 PM, Daniel Linder wrote: > I'm trying to pro-actively monitor the "real world" speed that I'm > getting > with my @Work connection. ... > Questions: > 1: Has anyone run across a tool like this that is free and will run > on Linux? I haven't heard of such a thing. I would think that monitoring your bandwidth by frequently flooding your network with downloads wouldn't be a terribly popular tool. :) That said, you can stick any numbers you want into RRDTool and it will keep your historical trends and generate all your graphs for you. I have written some Perl wrappers to throw miscellaneous statistics into RRDTool every 5 minutes (via cron), and it does all the hard work for me. > 2: If I stared to write something like this, has anyone got some > Perl code > to grab random URLs from a search engine? Umm... I guess you could use WWW::Mechanize to feed a random word from your local dictionary to Google and hit the "I'm feeling lucky" button. But that's not really trending *your* bandwidth because the random server on the other end could have bandwidth problems of its own and you'd have no way of seeing the difference between your bandwidth and theirs. It seems to me to trend your bandwidth you'd have to hit a known big pipe every time, and just assume that your chosen victim always has "unlimited" bandwidth and never has server or congestion trouble of any kind. Intentionally and systematically wasting bandwidth seems a strange first step towards getting more bandwidth, which is, I assume, your ultimate goal. :) j From jhannah at omnihotels.com Wed Jul 18 13:33:48 2007 From: jhannah at omnihotels.com (Jay Hannah) Date: Wed, 18 Jul 2007 15:33:48 -0500 Subject: [Omaha.pm] XML::Twig, get_xpath are cool Message-ID: The fact that you can hop up to your parent element with ../ in xpath is just way too cool. :) j $ cat j.pl use XML::Twig; my $xml = grab_xml(); my $twig = XML::Twig->new(); $twig->parse($xml); my $root = $twig->root; foreach my $i ($root->get_xpath('Inventories/Inventory/StatusApplicationControl')) { print $i->{att}->{InvType}; foreach my $j ($i->get_xpath('../InvCounts/InvCount')) { print " " . $j->{att}->{Count}; } print "\n"; } sub grab_xml { return < EOT } $ perl j.pl RODG -2 KNSUP -95 THOR 1000 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/omaha-pm/attachments/20070718/dcbde884/attachment.html From jhannah at omnihotels.com Mon Jul 23 17:51:45 2007 From: jhannah at omnihotels.com (Jay Hannah) Date: Mon, 23 Jul 2007 19:51:45 -0500 (CDT) Subject: [Omaha.pm] IO::Multiplex + IO::Socket::SSL ? Message-ID: Hi Rob, Steffen -- I am wondering if anyone has had success using IO::Socket::SSL and IO::Multiplex together? I use the heck out of IO::Multiplex with IO::Socket::INET, and it works great. In IO::Socket::SSL, I got example/ssl_server.pl working great. But I can't seem to get IO::Socket::SSL to work correctly inside the IO::Multiplex listen() framework. I'm running the current versions of everything (err... except perl itself), per the bottom of this email. But it seems no matter what combination of options I do or don't pass into IO::Socket::SSL->new() I never get a functional $$input. mux_input() is firing, so that's good, so I'm wondering if I'm just missing something really simple? IO::Multiplex /Changes mentions IO::Socket::SSL... so it does work? Thanks for your help!! j # -------------------------------------------- # The source code of my program... # -------------------------------------------- $ cat j.pl use IO::Socket::INET; use IO::Socket::SSL qw( debug4 ); use IO::Multiplex; use FileHandle; STDOUT->autoflush(); my $mux = new IO::Multiplex; my $sock = IO::Socket::INET->new( Listen => 100, LocalAddr => '10.0.33.98', LocalPort => 9000, Proto => 'tcp', ); my $sock_ssl = IO::Socket::SSL->new( Listen => 100, LocalAddr => '10.0.33.98', LocalPort => 9001, Proto => 'tcp', Reuse => 1, SSL_verify_mode => 0x01, SSL_passwd_cb => sub {return "bluebell"}, SSL_use_cert => 1, # core.pm has both the private key and the cert file in it... SSL_ca_file => '/home/jhannah/src/Omni/MVC/Control/Multiplex/Buffer/TCP/ca.pem', SSL_key_file => '/home/jhannah/src/Omni/MVC/Control/Multiplex/Buffer/TCP/core.pem', SSL_cert_file => '/home/jhannah/src/Omni/MVC/Control/Multiplex/Buffer/TCP/core.pem', ); $mux->listen($sock); $mux->listen($sock_ssl); $mux->set_callback_object(__PACKAGE__); $mux->loop; sub mux_input { my ($self, $mux, $fh, $input) = @_; print "mux_input:\n-------------------------\n$$input\n---------------------\n"; print $fh "Hello, Firefox!\n"; #$$input = ''; # Explodes when using IO::Socket::SSL close $fh; } # -------------------------------------------- When the program is running and I hit http://10.0.33.98:9000/ (IO::Socket::INET) it works fine (with warnings). I see all the client headers in mux_input. But when I hit https://10.0.33.98:9001/ (IO::Socket::SSL) all I get in mux_input is a bunch of binary garbledy gook, below. (If I don't try to use IO::Socket::SSL at all there are no warnings.) $ perl j.pl Undefined SSL object at /usr/lib/perl5/site_perl/5.8.7/IO/Multiplex.pm line 577 Undefined SSL object at /usr/lib/perl5/site_perl/5.8.7/IO/Multiplex.pm line 577 mux_input: ------------------------- GET / HTTP/1.1 Host: razorbill.omnihotels.com:9000 User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.5) Gecko/20070713 Firefox/2.0.0.5 Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive --------------------- Undefined SSL object at /usr/lib/perl5/site_perl/5.8.7/IO/Multiplex.pm line 577 Undefined SSL object at /usr/lib/perl5/site_perl/5.8.7/IO/Multiplex.pm line 577 Undefined SSL object at /usr/lib/perl5/site_perl/5.8.7/IO/Multiplex.pm line 577 Undefined SSL object at /usr/lib/perl5/site_perl/5.8.7/IO/Multiplex.pm line 577 mux_input: ------------------------- ?V????h9?1G??!? *C]Wl5I]??H ?N?0?T???k6??mc?? ????`????o?????]??=???6???t=?6?U?|i????}?\1k%????C???=s??5????:??^??S????8????;?$??288Z?u??-r{r??YV??(?4??j???)?r ???7%?v ???r?M ?8bl???X??&S???(d){4.8b???B???|xYv?R Q???f"?r$ ga???K['!???=s??I|/??%????k??q4)??? ? --------------------- Undefined SSL object at /usr/lib/perl5/site_perl/5.8.7/IO/Multiplex.pm line 577 Undefined SSL object at /usr/lib/perl5/site_perl/5.8.7/IO/Multiplex.pm line 577 Undefined SSL object at /usr/lib/perl5/site_perl/5.8.7/IO/Multiplex.pm line 577 $ perl -MIO::Socket::SSL -e 'print $IO::Socket::SSL::VERSION' 0.97 $ perl -MIO::Multiplex -e 'print $IO::Multiplex::VERSION' 1.09 $ perl -MNet::SSLeay -e 'print $Net::SSLeay::VERSION' 1.30 $ perl -v This is perl, v5.8.7 built for i686-linux I re-built Net::SSLeay to make sure it's using the very latest OpenSSL: $ perl Makefile.PL Checking for OpenSSL-0.9.6j or 0.9.7b or newer... You have OpenSSL-0.9.8e installed in /usr/local/ssl That's is newer than what this module was tested with (0.9.6j or 0.9.7b). You should consider checking if there is a newer release of this module available. Everything will probably work OK, though. From andy at petdance.com Mon Jul 30 09:00:26 2007 From: andy at petdance.com (Andy Lester) Date: Mon, 30 Jul 2007 11:00:26 -0500 Subject: [Omaha.pm] Help the Perl community better understand its users at perlsurvey.org Message-ID: (Please feel free to forward this to anyone who might be able to help, such as other mailing lists. -- Andy) What sort of programmer uses Perl? Do most Perl programmers use it as a primary language, or just write the occasional script? And are there really as few women as conventional wisdom says? Kirrily Robert wants to know, and wants anyone around the world who uses Perl to help by answering a simple five-minute survey at perlsurvey.org. Kirrily's goal is to "take a snapshot of the Perl world as it currently stands." As an active member of the Perl community, she's often asked questions about Perl's users and is only left to "hypothesise, generalise, and hand-wave." Further, software communities can often be an echo chamber where people only hear from like-minded people. The Perl Survey is an attempt to break out of that echo chamber and hear from all Perl users around the world, regardless of skill level, not just the core users most active in vocal communities. An interesting part of the survey is asking the respondent's salary, if they choose to release it. "I hear a lot of talk about the going rate for Perl programmers," Kirrily says, "and whether organizations that claim they can't hire Perl programmers simply aren't paying enough." Correlating results with job experience and types of languages known could shed light on the topic. The survey's reach could help users around the world. "Salary information can be very hard to find out for anywhere other than the US," says Kirrily, an Australian. The survey will be open until September 30, 2007. Then, in October, Kirrily will be announcing the results and releasing the raw data, minus email addresses, under a Creative Commons "CC-BY" license. Her hope is that other interested people will provide their own analyses of the results. For further information, and to participate if you use Perl at all, visit perlsurvey.org. Thanks, xoxo, Andy -- Andy Lester => andy at petdance.com => www.petdance.com => AIM:petdance From jay at jays.net Mon Jul 30 13:00:57 2007 From: jay at jays.net (Jay Hannah) Date: Mon, 30 Jul 2007 15:00:57 -0500 Subject: [Omaha.pm] IO::Multiplex + IO::Socket::SSL ? In-Reply-To: References: Message-ID: <46AE4379.2000701@jays.net> Here was Steffen's response. No response from Rob... I don't think my company wants me to spend the time it would take to get into the guts of this, so I think maybe I'm SOL... Ugly work-around time...? j From: Steffen Ullrich [mailto:Steffen_Ullrich at genua.de] Sent: Tuesday, July 24, 2007 6:53 AM To: Jay Hannah Cc: bbb at cpan.org; omaha-pm at pm.org Subject: Re: IO::Multiplex + IO::Socket::SSL ? Hi, Looks like IO::Multiplex assumes that an accept(2) either fails permanently or succeeds immediatly, which is usually the case, because the kernel already established the connection and just needs to give a new file descriptor to user space. But with an SSL socket it is different, because accept not only needs to establish the TCP connection but it also does the SSL handshake. With the "old" IO::Socket::SSL ( <= version 0.97 ) accept would block for the handshake, even if the socket was set to non-blocking. With the newer version accept returns EAGAIN and should be called again later. Depending on the value of $SSL_ERROR it should be called again when the fd gets readable (SSL_WANT_READ) or writable (SSL_WANT_WRITE). But the best thing would be to call accept only on the underlying IO::Socket::INET object and then upgrade the result with accept_SSL, because only in this case one could handle multiple accepts in parallel. But even then I have doubts, that IO::Multiplex works fine with IO::Socket::SSL. It uses POSIX::read and POSIX::write to write directly to the file descriptors instead of using sysread und syswrite, which wrap around SSL_read and SSL_write from openssl. So it would maybe establish an SSL connection but then write unencrypted data to it which the peer does not expect. Regards, Steffen From jay at jays.net Mon Jul 30 13:51:57 2007 From: jay at jays.net (Jay Hannah) Date: Mon, 30 Jul 2007 15:51:57 -0500 Subject: [Omaha.pm] [olug] [OT]: Learning Perl Resources In-Reply-To: <200707300707.44318.dthacker9@cox.net> References: <5aaed53f0707291957v5ac6d476r9d028101c935dcf0@mail.gmail.com> <137733690BE34D27848AEADC86E32DE2@StanVista> <200707300707.44318.dthacker9@cox.net> Message-ID: <46AE4F6D.7030300@jays.net> Ooo... Dave is out pimping the Perl. :) j Dave Thacker wrote: > On Sunday 29 July 2007 22:25, Stan Coleman wrote: > >> I'm looking at learning a new program language this fall. Which is better >> Pearl or Phython or ???? >> > > Try them both and see which one you like. I've spent more time with perl than > python, so I'm familiar with it's resources. > > >> What resourse (books website etc.) would you recomend if I wanted to teach >> myself? Or would you recomend me taking a class from some where? >> > > For perl I recommend: > > Books > Learning Perl, published by O'Reilly > > Websites > http://learn.perl.org/ > http://www.perlmonks.org > > Mailing Lists > The perl beginners mailing list: > http://lists.cpan.org/showlist.cgi?name=beginners > > Local Groups > Omaha Perl Mongers: http://omaha.pm.org/ > > I'm sure there similar resources for python. > > As far as books vs classes, it depends on you and the way you learn best. If > you are self teaching, I recommend picking a problem that you want to solve > and use your language of choice to solve it. Have fun! > > Dave > _______________________________________________ > OLUG mailing list > OLUG at olug.org > http://lists.olug.org/mailman/listinfo/olug > From jhannah at omnihotels.com Tue Jul 31 12:17:07 2007 From: jhannah at omnihotels.com (Jay Hannah) Date: Tue, 31 Jul 2007 14:17:07 -0500 Subject: [Omaha.pm] Substitution loop Message-ID: Huh... I've never seen this one before... Substitution loop at CommonShare.pm line 65. line 65 looks harmless enough: $d1=~s/[^\d]//g; Anyone seen that error before? Diving.... :) j From andy at petdance.com Tue Jul 31 12:38:02 2007 From: andy at petdance.com (Andy Lester) Date: Tue, 31 Jul 2007 14:38:02 -0500 Subject: [Omaha.pm] Substitution loop In-Reply-To: References: Message-ID: <51074433-AF40-45D0-B0DF-0E1ECBF9B0B0@petdance.com> On Jul 31, 2007, at 2:17 PM, Jay Hannah wrote: > Substitution loop at CommonShare.pm line 65. > > line 65 looks harmless enough: > > $d1=~s/[^\d]//g; > > Anyone seen that error before? > > Diving.... :) Sure. The /g is a modifier saying "do this on everything throughout the string". In this case, it's removing every non-digit character from the string. It would be even better to have it as $dl =~ s/[^\d]+//g; That way if you have a string of ten non-digits, they'll all get removed at once, rather via ten checks. You can also use the tr/// operator for this sort of thing, if you want. xoxo, Andy -- Andy Lester => andy at petdance.com => www.petdance.com => AIM:petdance From jay at jays.net Tue Jul 31 13:09:57 2007 From: jay at jays.net (Jay Hannah) Date: Tue, 31 Jul 2007 15:09:57 -0500 Subject: [Omaha.pm] Substitution loop In-Reply-To: <51074433-AF40-45D0-B0DF-0E1ECBF9B0B0@petdance.com> References: <51074433-AF40-45D0-B0DF-0E1ECBF9B0B0@petdance.com> Message-ID: On Jul 31, 2007, at 2:38 PM, Andy Lester wrote: > Sure. The /g is a modifier saying "do this on everything throughout > the string". In this case, it's removing every non-digit character > from the string. > > It would be even better to have it as > > $dl =~ s/[^\d]+//g; > > That way if you have a string of ten non-digits, they'll all get > removed at once, rather via ten checks. > > You can also use the tr/// operator for this sort of thing, if you > want. Yes, those are great tips. Thanks! But what is a fatal "Substitution loop" error from Perl? I've never seen that one before. It disappeared without me changing anything and I can't make it happen again. Probably user error. :) j From dan at linder.org Tue Jul 31 13:11:58 2007 From: dan at linder.org (Dan Linder) Date: Tue, 31 Jul 2007 15:11:58 -0500 Subject: [Omaha.pm] Substitution loop In-Reply-To: <51074433-AF40-45D0-B0DF-0E1ECBF9B0B0@petdance.com> References: <51074433-AF40-45D0-B0DF-0E1ECBF9B0B0@petdance.com> Message-ID: <46AF978E.8000200@linder.org> On Jul 31, 2007, at 2:17 PM, Jay Hannah wrote: > Substitution loop at CommonShare.pm line 65. > > line 65 looks harmless enough: > > $d1=~s/[^\d]//g; > > Anyone seen that error before? > > Diving.... :) > Andy Lester wrote: > You can also use the tr/// operator for this sort of thing, if you want. > > Jay, You said "Anyone seen that error before?" Did you mean to include the CommonShare.pm or a snippet of code? I've used the s///g; many times before and never really had a problem with it. (Note, I don't optimize for execution speed, rather readability and future "3AM support".) It would be interesting to know which benchmarks faster, the "s///g" or "tr///" on your data... Dan -- - - - - "Wait for that wisest of all counselors, time." -- Pericles "I do not fear computers, I fear the lack of them." -- Isaac Asimov From dan at linder.org Tue Jul 31 13:18:08 2007 From: dan at linder.org (Dan Linder) Date: Tue, 31 Jul 2007 15:18:08 -0500 Subject: [Omaha.pm] Substitution loop In-Reply-To: References: <51074433-AF40-45D0-B0DF-0E1ECBF9B0B0@petdance.com> Message-ID: <46AF9900.40700@linder.org> Jay Hannah wrote: > But what is a fatal "Substitution loop" error from Perl? > > I've never seen that one before. It disappeared without me changing > anything and I can't make it happen again. > > Probably user error. :) > From "http://search.cpan.org/~nwclark/perl-5.8.8/pod/perldiag.pod": Substitution loop : (P) The substitution was looping infinitely. (Obviously, a substitution shouldn't iterate more times than there are characters of input, which is what happened.) See the discussion of substitution in "Quote and Quote-like Operators" in perlop. I can't see how the simple "$d1=~s/[^\d]//g;" could cause the loop as described above -- what happens if $d1 was all numbers - if there is a bug in the length check, then it could count X characters but try to run X+1 times and get that error... (Just a shot in the dark, though.) Do you have a way of catching the error next time and logging the initial contents of $d1? Dan -- - - - - "Wait for that wisest of all counselors, time." -- Pericles "I do not fear computers, I fear the lack of them." -- Isaac Asimov From rob.townley at gmail.com Tue Jul 31 13:47:19 2007 From: rob.townley at gmail.com (Rob Townley) Date: Tue, 31 Jul 2007 15:47:19 -0500 Subject: [Omaha.pm] Substitution loop In-Reply-To: <46AF9900.40700@linder.org> References: <51074433-AF40-45D0-B0DF-0E1ECBF9B0B0@petdance.com> <46AF9900.40700@linder.org> Message-ID: <7e84ed60707311347n28817ee7ga97d49928fee46f9@mail.gmail.com> On 7/31/07, Dan Linder wrote: > > Jay Hannah wrote: > > But what is a fatal "Substitution loop" error from Perl? > > > > I've never seen that one before. It disappeared without me changing > > anything and I can't make it happen again. > > > > Probably user error. :) > > > From "http://search.cpan.org/~nwclark/perl-5.8.8/pod/perldiag.pod": > Substitution loop : (P) The substitution was looping infinitely. > (Obviously, a substitution shouldn't iterate more times than there are > characters of input, which is what happened.) See the discussion of > substitution in "Quote and Quote-like Operators" in perlop. > > I can't see how the simple "$d1=~s/[^\d]//g;" could cause the loop as > described above -- what happens if $d1 was all numbers - if there is a > bug in the length check, then it could count X characters but try to run > X+1 times and get that error... (Just a shot in the dark, though.) > > Do you have a way of catching the error next time and logging the > initial contents of $d1? > > Dan > > -- > - - - - > "Wait for that wisest of all counselors, time." -- Pericles "I do not > fear computers, I fear the lack of them." -- Isaac Asimov > > > _______________________________________________ > Omaha-pm mailing list > Omaha-pm at pm.org > http://mail.pm.org/mailman/listinfo/omaha-pm > i bet it depends on the content of the string input - if you have all digits, i bet you do not get an error. Doesn't it mean that you putting into the s string a character that is not a number, so it is replaced again, then removed again, replaced ad infinitum. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/omaha-pm/attachments/20070731/e511715d/attachment.html From jay at jays.net Tue Jul 31 13:52:56 2007 From: jay at jays.net (Jay Hannah) Date: Tue, 31 Jul 2007 15:52:56 -0500 Subject: [Omaha.pm] Substitution loop In-Reply-To: <46AF9900.40700@linder.org> References: <51074433-AF40-45D0-B0DF-0E1ECBF9B0B0@petdance.com> <46AF9900.40700@linder.org> Message-ID: On Jul 31, 2007, at 3:18 PM, Dan Linder wrote: > Do you have a way of catching the error next time and logging the > initial contents of $d1? Ya, I immediately tried to run the program again in the debugger and "x $d1" to see how on earth I threw that error. The error did not recur in the debugger or w/ a normal run of the program. Poof! Self-correcting code! I love it! :) j ...just like The Amazing Jonathan From jay at jays.net Tue Jul 31 14:16:19 2007 From: jay at jays.net (Jay Hannah) Date: Tue, 31 Jul 2007 16:16:19 -0500 Subject: [Omaha.pm] Substitution loop In-Reply-To: <46AF978E.8000200@linder.org> References: <51074433-AF40-45D0-B0DF-0E1ECBF9B0B0@petdance.com> <46AF978E.8000200@linder.org> Message-ID: <44186C2F-4B14-4D5D-ADD8-D633FD25506F@jays.net> On Jul 31, 2007, at 3:11 PM, Dan Linder wrote: > You said "Anyone seen that error before?" Did you mean to include the > CommonShare.pm or a snippet of code? My original post contained the line of code: > line 65 looks harmless enough: > > $d1=~s/[^\d]//g; Additional context won't help since $d1 is passed into the subroutine which contains line 65. Hence my immediate debugger attempt. > I've used the s///g; many times before and never really had a > problem with it. Yup. s///g is one of many indispensable tools in the Perl 101 toolbox. > (Note, I don't optimize for execution speed, rather readability and > future "3AM support".) Indeed. The vast majority of time that is the way to go. Programmer time is orders of magnitude more expensive than a few extra CPU cycles nowadays. :) j From jay at jays.net Tue Jul 31 14:33:55 2007 From: jay at jays.net (Jay Hannah) Date: Tue, 31 Jul 2007 16:33:55 -0500 Subject: [Omaha.pm] Wiki Message-ID: <4F94116F-1A08-4AA8-81C3-E74C52AD98C6@jays.net> Someone whacked our wiki. I put it back. http://omaha.pm.org/kwiki/ j From jay at jays.net Tue Jul 31 17:18:08 2007 From: jay at jays.net (Jay Hannah) Date: Tue, 31 Jul 2007 19:18:08 -0500 Subject: [Omaha.pm] [olug] ANN: Omaha Python Users Group Meeting, Aug 1 @ 7pm In-Reply-To: <5aaed53f0707302048k2c0c8862k2be3a9c555f45388@mail.gmail.com> References: <5aaed53f0707291957v5ac6d476r9d028101c935dcf0@mail.gmail.com> <137733690BE34D27848AEADC86E32DE2@StanVista> <200707301712.16251.luke@dashjr.org> <46AEABBF.6060206@shwisp.net> <5aaed53f0707302048k2c0c8862k2be3a9c555f45388@mail.gmail.com> Message-ID: On Jul 30, 2007, at 10:48 PM, Jeff Hinrichs - DM&T wrote: > On 7/30/07, Sam Tetherow wrote: >> There is a big difference between should and must. > Yes, there is. Must is enforced by the interpreter/compiler, should > is enforced by convention. > Just because you can, doesn't mean you should. ;) > With python, whitespace is not a should, it is a must. Perl lets you choose. You can clean dirty code if you want and/or you can enforce your own best practices automatically: http://www252.pair.com/comdog/mastering_perl/Chapters/ 07.cleaning_up_code.html Cheers, j Omaha Perl Mongers: http://omaha.pm.org From jay at jays.net Tue Jul 31 17:29:35 2007 From: jay at jays.net (Jay Hannah) Date: Tue, 31 Jul 2007 20:29:35 -0400 (EDT) Subject: [Omaha.pm] Substitution loop In-Reply-To: References: <51074433-AF40-45D0-B0DF-0E1ECBF9B0B0@petdance.com> Message-ID: Got you, you sneaky little !*#*!(!#$&*!!! Below. Amazingly those UTF-8 warnings don't kick unless I "p $d1". "x $d1" is not sufficient to see what's actually going on. j (wondering when we adopted UTF-8 in this database) Model::OTA::CommonShare::_update_start(/home/jhannah/src/Omni/MVC/Model/OTA/CommonShare.pm:65): 65: $d1=~s/[^\d]//g; DB<11> c Model::OTA::CommonShare::_update_start(/home/jhannah/src/Omni/MVC/Model/OTA/CommonShare.pm:65): 65: $d1=~s/[^\d]//g; DB<11> x $d1 0 '2007-08-11' DB<12> p $d1 2007-08-11 DB<13> c Malformed UTF-8 character (overflow at 0xc9237b89, byte 0x95, after start byte 0xff) in substitution (s///) at /home/jhannah/src/Omni/MVC/Model/OTA/CommonShare.pm line 65. ...stack trace here... Malformed UTF-8 character (unexpected continuation byte 0x95, with no preceding start byte) in substitution iterator at /usr/lib/perl5/5.8.7/Carp/Heavy.pm line 61. Malformed UTF-8 character (unexpected non-continuation byte 0x12, 1 byte after start byte 0xe0, expected 3 bytes) in substitution iterator at /usr/lib/perl5/5.8.7/Carp/Heavy.pm line 61. Substitution loop at /usr/lib/perl5/5.8.7/Carp/Heavy.pm line 61. ...snip!... From jay at jays.net Tue Jul 31 21:12:27 2007 From: jay at jays.net (Jay Hannah) Date: Tue, 31 Jul 2007 23:12:27 -0500 Subject: [Omaha.pm] Substitution loop In-Reply-To: References: <51074433-AF40-45D0-B0DF-0E1ECBF9B0B0@petdance.com> Message-ID: <009F87F2-903A-46C7-B783-D8CEBC9464FB@jays.net> On Jul 31, 2007, at 7:29 PM, Jay Hannah wrote: > Model::OTA::CommonShare::_update_start(/home/jhannah/src/Omni/MVC/ > Model/OTA/CommonShare.pm:65): > 65: $d1=~s/[^\d]//g; > > DB<11> x $d1 > 0 '2007-08-11' > > DB<12> p $d1 > 2007-08-11 > > DB<13> c > Malformed UTF-8 character (overflow at 0xc9237b89, byte 0x95, after > start byte 0xff) in substitution (s///) at /home/jhannah/src/Omni/ > MVC/Model/OTA/CommonShare.pm line 65. > ...stack trace here... > Malformed UTF-8 character (unexpected continuation byte 0x95, with > no preceding start byte) in substitution iterator at /usr/lib/ > perl5/5.8.7/Carp/Heavy.pm line 61. > Malformed UTF-8 character (unexpected non-continuation byte 0x12, 1 > byte after start byte 0xe0, expected 3 bytes) in substitution > iterator at /usr/lib/perl5/5.8.7/Carp/Heavy.pm line 61. > Substitution loop at /usr/lib/perl5/5.8.7/Carp/Heavy.pm line 61. > ...snip!... Well, I have no idea why UTF-8 is involved at all, let alone malformed UTF-8. Adding this line sidesteps the error: utf8::downgrade($d1); As does changing line 65 to: $d1 =~ s/\D+//g; I don't understand, but have spent too much time on this already. Time to move back to battles I know how to fight. :) j