From jhannah at omnihotels.com Fri Apr 1 12:28:10 2005 From: jhannah at omnihotels.com (Jay Hannah) Date: Fri Apr 1 12:28:08 2005 Subject: [Omaha.pm] Talk about brute forcing a problem... Message-ID: <200504012027.j31KRwxm014748@omares-email.omnihotels.com> Just when I thought *I* was guilty of brute forcing things too much... -grin- http://www.cpan.org/authors/id/Q/QU/QUBE/primes.pl PRIMETEST: for ($count1=1;$count1 <= $prime_candidate / 2;$count1++) { for ($count2=1;$count2 <= $prime_candidate /2;$count2++) { if ($count1 * $count2 == $prime_candidate) { $truth = 0; last PRIMETEST; } } } Wow. Aren't there smarter/faster mathmetical ways to find primes? j From andy at petdance.com Fri Apr 1 13:31:23 2005 From: andy at petdance.com (Andy Lester) Date: Fri Apr 1 13:31:31 2005 Subject: [Omaha.pm] Talk about brute forcing a problem... In-Reply-To: <200504012027.j31KRwxm014748@omares-email.omnihotels.com> References: <200504012027.j31KRwxm014748@omares-email.omnihotels.com> Message-ID: <20050401213123.GC14744@petdance.com> On Fri, Apr 01, 2005 at 02:28:10PM -0600, Jay Hannah (jhannah@omnihotels.com) wrote: > Wow. Aren't there smarter/faster mathmetical ways to find primes? Yes. -- Andy Lester => andy@petdance.com => www.petdance.com => AIM:petdance From jhannah at omnihotels.com Mon Apr 4 12:02:31 2005 From: jhannah at omnihotels.com (Jay Hannah) Date: Mon Apr 4 12:02:31 2005 Subject: [Omaha.pm] Test::More is_deeply() Message-ID: <200504041902.j34J2Hxm001639@omares-email.omnihotels.com> Wow. is_deeply() is pretty slick. >From the POD: is_deeply is_deeply( $this, $that, $test_name ); Similar to is(), except that if $this and $that are hash or array references, it does a deep comparison walking each data structure to see if they are equiva- lent. If the two structures are different, it will display the place where they start differing. Over in my test script: ok(@cros = $f->get_cro_resnos, "get_cro_resnos()"); my @should_be = qw(1004427653 1080835469 1004678589 1004763984); is_deeply(\@cros, \@should_be, " is what we expected"); I've intentionally screwed up the second element of the array, so is_deeply() magically tells me exactly where things went amiss: ok 4 - get_cro_resnos() not ok 5 - is what we expected # Failed test (Inbound.t at line 14) # Structures begin differing at: # $got->[1] = '1090835469' # $expected->[1] = '1080835469' Cool... j From jhannah at omnihotels.com Wed Apr 6 14:00:47 2005 From: jhannah at omnihotels.com (Jay Hannah) Date: Wed Apr 6 14:00:54 2005 Subject: [Omaha.pm] RE: Wow! I used map! Message-ID: <200504062100.j36L0Wxm032290@omares-email.omnihotels.com> > my ($dir, @files); > foreach $dir ($in_dir, $waiting_in_dir) { > opendir(DIR, $dir); > push @files, map { $_ = "$dir/$_" } readdir DIR; > closedir DIR; > } Then, of course, I need a custom sort sub so the path is ignored when sorting... -grin- j print join "\n", sort by_filename_date @files; sub by_filename_date { my $j = uc($a); my $k = uc($b); $j =~ s/.*\///; $k =~ s/.*\///; $j cmp $k; } From jhannah at omnihotels.com Wed Apr 6 13:51:05 2005 From: jhannah at omnihotels.com (Jay Hannah) Date: Wed Apr 6 14:13:40 2005 Subject: [Omaha.pm] Wow! I used map! Message-ID: <200504062050.j36Kopxm007813@omares-email.omnihotels.com> I never ever ever use map. Until today. I've played w/ it over the years, but I think this is the first time I've consciously set out to use it. ---------- my $out_dir = "/datamining/rewards/deliver/sent"; my $in_dir = "/datamining/rewards/receive/processed/UA"; my $waiting_in_dir = "/datamining/rewards/receive"; my ($dir, @files); foreach $dir ($in_dir, $waiting_in_dir) { opendir(DIR, $dir); push @files, map { $_ = "$dir/$_" } readdir DIR; closedir DIR; } @files = grep { /OMNIERROR/i } @files; ------------- This'd is a lot less code: my @files = `ls $in_dir $waiting_in_dir`; for (@files) { chomp; } but wouldn't have the filenames and forking shells isn't efficient (not that I care in this program)... opendir, readdir, closedir has always struck me as one of the clunkiest areas Perl. j From jhannah at omnihotels.com Wed Apr 6 16:07:00 2005 From: jhannah at omnihotels.com (Jay Hannah) Date: Wed Apr 6 16:06:59 2005 Subject: [Omaha.pm] Stack traces rule! Message-ID: <200504062306.j36N6kxm024627@omares-email.omnihotels.com> ('T' in the debugger) How else could you ever trace goo like this? Neato, j 2005-04-06 18:02:07,846 (SlaveBot.pm:118)> cro_resno:1004411618|airline_ff_id:00300560016|partner_id:UA|class:Model::omares::crs::Rewards 2005-04-06 18:02:08,385 (SlaveBot.pm:126)> Successfully loaded fg_id:14040489 2005-04-06 18:02:08,388 (SlaveBot.pm:191)> status_program:000|status_omni:900 Model::omares::Prod::Common::load(/usr/lib/perl5/site_perl/Omni/MVC/Model/omares/Prod/Common.pm:720): 720: $self->set_error(code=>2920,text=>"No data in $table for filter $filter."); DB<5> T $ = Model::omares::Prod::Common::load(ref(Model::omares::Prod::user), 'filter', 'user_id=\'SB-RECEIVE_FILE()\'') called from file `/usr/lib/perl5/site_perl/Omni/MVC/Model/omares/crs/Permissions.pm' line 146 $ = Model::omares::crs::Permissions::load_user(ref(Model::omares::crs::Permissions), 'user_id', 'SB-RECEIVE_FILE()') called from file `/usr/lib/perl5/site_perl/Omni/MVC/Model/omares/crs/Permissions.pm' line 120 $ = Model::omares::crs::Permissions::load(ref(Model::omares::crs::Permissions), 'user_id', 'SB-RECEIVE_FILE()') called from file `/usr/lib/perl5/site_perl/Omni/MVC/Model/omares/Prod/Common.pm' line 220 $ = Model::omares::Prod::Common::_calculate_res_source(ref(Model::omares::Prod::fg_rewards)) called from file `/usr/lib/perl5/site_perl/Omni/MVC/Model/omares/Prod/Common.pm' line 169 . = Model::omares::Prod::Common::set_who_and_when(ref(Model::omares::Prod::fg_rewards)) called from file `/usr/lib/perl5/site_perl/Omni/MVC/Model/omares/Prod/Common.pm' line 383 $ = Model::omares::Prod::Common::update(ref(Model::omares::Prod::fg_rewards), 'filter', 'fg_id = \'14040489\' and cro_resno = \'1004411618\'') called from file `/usr/lib/perl5/site_perl/Omni/MVC/Model/omares/crs/Rewards.pm' line 541 . = Model::omares::crs::Rewards::_fg_rewards_commit(ref(Model::omares::crs::Rewards)) called from file `/usr/lib/perl5/site_perl/Omni/MVC/Model/omares/crs/Rewards.pm' line 504 . = Model::omares::crs::Rewards::change_omni_status(ref(Model::omares::crs::Rewards), 900) called from file `/usr/lib/perl5/site_perl/Omni/MVC/Model/Rewards/SlaveBot.pm' line 233 . = Model::Rewards::SlaveBot::receive_file(ref(Model::Rewards::SlaveBot), 'local_filename', 'OMNIERROR_20050218_3', 'partner_id', 'UA') called from file `receive.pl' line 19 From jay at jays.net Wed Apr 6 17:21:26 2005 From: jay at jays.net (Jay Hannah) Date: Wed Apr 6 17:21:35 2005 Subject: [Omaha.pm] Wow! I used map! In-Reply-To: <200504062050.j36Kopxm007813@omares-email.omnihotels.com> References: <200504062050.j36Kopxm007813@omares-email.omnihotels.com> Message-ID: Wow. I must have been drunk when I wrote that email... On Apr 6, 2005, at 3:51 PM, Jay Hannah wrote: > This'd is a lot less code: I meant "This would be". > but wouldn't have the filenames I meant "file paths". > of the clunkiest areas Perl. clunkiest areas OF Perl. I gotzta stop doing 10 things at once. Sigh, j From andy at petdance.com Wed Apr 6 22:26:57 2005 From: andy at petdance.com (Andy Lester) Date: Wed Apr 6 22:27:11 2005 Subject: [Omaha.pm] Wow! I used map! In-Reply-To: <200504062050.j36Kopxm007813@omares-email.omnihotels.com> References: <200504062050.j36Kopxm007813@omares-email.omnihotels.com> Message-ID: <20050407052657.GA771@petdance.com> > push @files, map { $_ = "$dir/$_" } readdir DIR; Don't set $_. push @files, map { "$dir/$_" } readdir DIR; -- Andy Lester => andy@petdance.com => www.petdance.com => AIM:petdance From andy at petdance.com Wed Apr 6 22:33:40 2005 From: andy at petdance.com (Andy Lester) Date: Wed Apr 6 22:33:48 2005 Subject: [Omaha.pm] Stack traces rule! In-Reply-To: <200504062306.j36N6kxm024627@omares-email.omnihotels.com> References: <200504062306.j36N6kxm024627@omares-email.omnihotels.com> Message-ID: <20050407053340.GC771@petdance.com> On Wed, Apr 06, 2005 at 06:07:00PM -0500, Jay Hannah (jhannah@omnihotels.com) wrote: > > ('T' in the debugger) > > How else could you ever trace goo like this? cluck() and carp() in Carp.pm. xoxo, Andy -- Andy Lester => andy@petdance.com => www.petdance.com => AIM:petdance From tim.larson at physiciansmutual.com Thu Apr 7 11:05:55 2005 From: tim.larson at physiciansmutual.com (Timothy Larson) Date: Thu Apr 7 11:06:09 2005 Subject: [Omaha.pm] mod_perl 2 Message-ID: <42557683.1090203@pmic.com> Once upon a time I was interested in some web utilities using mod_perl, but then my free time waned. Now I have a little time again so I am trying to catch up on the past few years' activity. Is mod_perl 2 ready to use with Apache 2 yet? Have any/many/most of the numerous mod_perl projects been updated to use it? Where can I go to check on the status of mod_perl and related projects? Thanks, Tim -- Tim Larson Senior Web Developer Physicians' Mutual Insurance Company www.pmic.com ____________________________________________________________ This message and any attachments are confidential, may contain privileged information, and are intended solely for the recipient named above. If you are not the intended recipient, or a person responsible for delivery to the named recipient, you are notified that any review, distribution, dissemination or copying is prohibited. If you have received this message in error, you should notify the sender by return email and delete the message from your computer system. From jay at jays.net Fri Apr 8 13:15:01 2005 From: jay at jays.net (Jay Hannah) Date: Fri Apr 8 13:15:17 2005 Subject: [Omaha.pm] mod_perl 2 In-Reply-To: <42557683.1090203@pmic.com> References: <42557683.1090203@pmic.com> Message-ID: On Apr 7, 2005, at 1:05 PM, Timothy Larson wrote: > Once upon a time I was interested in some web utilities using > mod_perl, but then my free time waned. Now I have a little time again > so I am trying to catch up on the past few years' activity. Is > mod_perl 2 ready to use with Apache 2 yet? Have any/many/most of the > numerous mod_perl projects been updated to use it? We've been using Apache2 and mod_perl2 exclusively for quite a while. Everything we need/use works fine. I can't speak to general stats of MP1 project conversions. > Where can I go to check on the status of mod_perl and related projects? http://perl.apache.org/ Rock on, j From tim.larson at physiciansmutual.com Fri Apr 8 13:29:22 2005 From: tim.larson at physiciansmutual.com (Timothy Larson) Date: Fri Apr 8 13:29:41 2005 Subject: [Omaha.pm] mod_perl 2 In-Reply-To: References: <42557683.1090203@pmic.com> Message-ID: <4256E9A2.2000407@pmic.com> Jay Hannah wrote: > We've been using Apache2 and mod_perl2 exclusively for quite a while. > Everything we need/use works fine. I can't speak to general stats of MP1 > project conversions. The two I'm most interested in at the moment are Slash and Mason. It would be nice if there were some central point they all reported at. >> Where can I go to check on the status of mod_perl and related projects? > http://perl.apache.org/ OK, thanks. Several sites I've tried to look through were very hard to navigate to find anything useful. Thanks, Tim -- Tim Larson Senior Web Developer Physicians' Mutual Insurance Company www.pmic.com ____________________________________________________________ This message and any attachments are confidential, may contain privileged information, and are intended solely for the recipient named above. If you are not the intended recipient, or a person responsible for delivery to the named recipient, you are notified that any review, distribution, dissemination or copying is prohibited. If you have received this message in error, you should notify the sender by return email and delete the message from your computer system. From jay at jays.net Fri Apr 8 14:37:38 2005 From: jay at jays.net (Jay Hannah) Date: Fri Apr 8 14:37:47 2005 Subject: [Omaha.pm] mod_perl 2 In-Reply-To: <4256E9A2.2000407@pmic.com> References: <42557683.1090203@pmic.com> <4256E9A2.2000407@pmic.com> Message-ID: <65b112309541ff7811e44fa50f6bb6c0@jays.net> On Apr 8, 2005, at 3:29 PM, Timothy Larson wrote: > The two I'm most interested in at the moment are Slash and Mason. It > would be nice if there were some central point they all reported at. Slash as in Slashcode? We don't use either of those, sorry. > OK, thanks. Several sites I've tried to look through were very hard > to navigate to find anything useful. I would think the Slash and Mason project homepages would be pretty clear about their MP2 statuses? (Template Toolkit works great on Apache2, MP2.) j From jay at jays.net Fri Apr 8 16:25:38 2005 From: jay at jays.net (Jay Hannah) Date: Fri Apr 8 16:25:49 2005 Subject: [Omaha.pm] mod_perl 2 In-Reply-To: <65b112309541ff7811e44fa50f6bb6c0@jays.net> References: <42557683.1090203@pmic.com> <4256E9A2.2000407@pmic.com> <65b112309541ff7811e44fa50f6bb6c0@jays.net> Message-ID: <4ec6e21fe34c6176781fd24db65ed6b4@jays.net> > On Apr 8, 2005, at 3:29 PM, Timothy Larson wrote: >> The two I'm most interested in at the moment are Slash and Mason. It >> would be nice if there were some central point they all reported at. http://www.masonhq.com/code/history.html#v1.28 1.27 October 28, 2004 ENHANCEMENTS ? Full support for Apache2/mod_perl2. j From jay at jays.net Fri Apr 8 21:29:44 2005 From: jay at jays.net (Jay Hannah) Date: Fri Apr 8 21:29:54 2005 Subject: [Omaha.pm] Newer version of iPhoto my butt Message-ID: My uncle gave me a picture CD tonight he burned from iPhoto. But he's got the latest version and I haven't paid for that, so my iPhoto won't open the CD. Forget them, then. I'll just snag all the .jpg's straight off the iPhoto CD (directory tree) into a new single directory (w/ a unique filename). Then, once I've got a single dir with all .jpgs in it I'll have my old iPhoto import that dir. That'll teach Steve Jobs. Grin, j my $cnt = 1; open (IN, "find '/Volumes/iPhoto\ Library\ -\ 4\:5\:05' -iname '*.jpg' |"); while () { chomp; next if (/originals/i); next if (/thumbs/i); my $full_path = $_; my $file = $_; $file =~ s/.*\///; $cmd = "cp '$full_path' lynn_photos/$cnt-$file"; print "$cmd\n"; `$cmd`; $cnt++; } close IN; From glim at mycybernet.net Sun Apr 10 08:47:00 2005 From: glim at mycybernet.net (Gerard Lim) Date: Sun Apr 10 09:06:39 2005 Subject: [Omaha.pm] Reminder: Yet Another Perl Conference in Toronto, June 27 - 29 Message-ID: Yet Another YAPC::NA 2005 Conference Reminder --------------------------------------------- YAPC::NA 2005 is Yet Another Perl Conference, North America, this year to be held in downtown Toronto, Ontario, Canada, Mon - Wed 27 - 29 June 2005. Important Dates/Deadlines ------------------------- April 18 -- deadline for paper submissions May 12 -- last day of guaranteed accommodations YAPC::NA is a grassroots, all-volunteer conference. The speaker quality is high, the participants lively, and there are many extra social activities scheduled. We expect a bit over 400 people this year, and registration is proceeding faster this year than in the past. The registration cost is USD$85. Information on registration: http://yapc.org/America/register-2005.shtml http://yapc.org/America/registration-announcement-2005.txt Direct link to registration: http://donate.perlfoundation.org/index.pl?node=registrant%20info&conference_id=423 Want to be a speaker? Deadline for proposal submission is April 18, just over 1 week from now. Go to: http://yapc.org/America/cfp-2005.shtml Need accommodations in Toronto? Go to: http://yapc.org/America/accommodations-2005.shtml If you book before May 13 you will be guaranteed a hotel space. After that getting accommodations will become progressively more difficult. Prices we have arranged are in two different price ranges: approximately US$50 for a dorm room, US$72 for a decent hotel room. All accommodations are very nearby the conference venue. This message comes from the YAPC::NA 2005 organizers in Toronto.pm, http://to.pm.org/, on behalf of The Perl Foundation, http://www.perlfoundation.org/ We look forward to seeing you in Toronto! If you have any questions please contact na-help@yapc.org From tim.larson at physiciansmutual.com Mon Apr 11 06:27:01 2005 From: tim.larson at physiciansmutual.com (Timothy Larson) Date: Mon Apr 11 06:27:16 2005 Subject: [Omaha.pm] mod_perl 2 In-Reply-To: <4ec6e21fe34c6176781fd24db65ed6b4@jays.net> References: <42557683.1090203@pmic.com> <4256E9A2.2000407@pmic.com> <65b112309541ff7811e44fa50f6bb6c0@jays.net> <4ec6e21fe34c6176781fd24db65ed6b4@jays.net> Message-ID: <425A7B25.4070308@pmic.com> Jay Hannah wrote: > http://www.masonhq.com/code/history.html#v1.28 > > 1.27 October 28, 2004 > > ENHANCEMENTS > ? Full support for Apache2/mod_perl2. Gaah, must have blew right past that. *sigh* Thanks, Tim -- Tim Larson Senior Web Developer Physicians' Mutual Insurance Company www.pmic.com ____________________________________________________________ This message and any attachments are confidential, may contain privileged information, and are intended solely for the recipient named above. If you are not the intended recipient, or a person responsible for delivery to the named recipient, you are notified that any review, distribution, dissemination or copying is prohibited. If you have received this message in error, you should notify the sender by return email and delete the message from your computer system. From jhannah at omnihotels.com Thu Apr 14 15:22:19 2005 From: jhannah at omnihotels.com (Jay Hannah) Date: Thu Apr 14 15:22:16 2005 Subject: [Omaha.pm] Another 10 minute DB load hack Message-ID: <200504142222.j3EMM0mD021821@omares-email.omnihotels.com> 800 lines of Excel spreadsheet into a database in 15 minutes... j #!/usr/bin/perl use Omni::DB; my $dbh = Omni::DB::connect_prod; $dbh->do("delete from user_attrib where system = 'CMS'"); my $strsql = "insert into user_attrib values (?, 'CMS', ?, ?)"; my $sth = $dbh->prepare($strsql); while () { chomp; next unless (/\w/); tr/a-z/A-Z/; s/ADMINISTRATOR/ADMIN/; @l = split /\t/; $l[1] =~ s/\@.*//; #print "$l[1]|$l[2]|$l[0]|\n"; $sth->execute(@l[1,2,0]); } $dbh->commit; $dbh->disconnect; __DATA__ Manager bgarlington@nospam.com DALLBJ User gguyse@nospam.com DALLBJ User ckreklow@nospam.com DALLBJ ...etc... From jay at jays.net Sun Apr 17 09:59:57 2005 From: jay at jays.net (Jay Hannah) Date: Sun Apr 17 10:00:14 2005 Subject: [Omaha.pm] Crossword puzzle contest Message-ID: The Omaha Perl Mongers received their first piece of mail (not spam), ever. (Via my home address.) We must be official now. The mailer is in color and everything. -grin- It's an invite to participate in a Apress programming contest: http://apress.com/userGroups/crosswordpuzzle.html So if you're interested, have at it. Is there any crossword stuff on CPAN? -ponder- j From jhannah at omnihotels.com Tue Apr 19 14:48:31 2005 From: jhannah at omnihotels.com (Jay Hannah) Date: Tue Apr 19 14:48:34 2005 Subject: [Omaha.pm] FW: What happens on January 1, 2006? Message-ID: <200504192148.j3JLmFmD029222@omares-email.omnihotels.com> @ the watercooler today... j -----Original Message----- From: Jay Hannah [mailto:jhannah@omnihotels.com] Sent: Tuesday, April 19, 2005 4:46 PM Subject: RE: What happens on January 1, 2006? my $bdate = $q->param('birthmmddyyyy'); my $invalid; if(($bdate !~ /\//) && (($bdate > 2005) || ($bdate < (2005-100))) ) Looks funky to me. What format is $bdate in? I can't imagine that code works... It might if > and < were gt and lt and $bdate was in YYYY/MM/DD, but who uses that date format? j > -----Original Message----- > From: Sean Baker > Sent: Tuesday, April 19, 2005 3:43 PM > Subject: What happens on January 1, 2006? > > if(($bdate !~ /\//) && (($bdate > 2005) || ($bdate < (2005-100))) ) > > http://cvs/source/specific/sguest/www/admin/index.pl.diff?r1=1.92&r2=1.93 > > > Am I reading this wrong? From jhannah at omnihotels.com Tue Apr 19 15:01:07 2005 From: jhannah at omnihotels.com (Jay Hannah) Date: Tue Apr 19 15:01:05 2005 Subject: [Omaha.pm] Meeting this Thr, 7pm! Message-ID: <200504192200.j3JM0rmD027033@omares-email.omnihotels.com> http://omaha.pm.org I'll be giving another ad-hoc presentation: J's OO Perl Practicum #2 Converting procedural code to OO structures: How? And why? 5 proprietary vendor data formats in 1 OO framework Advantages, lessons learned, what could be better still, etc. j From mat at phpconsulting.com Tue Apr 19 15:16:37 2005 From: mat at phpconsulting.com (Mat Caughron) Date: Tue Apr 19 15:08:47 2005 Subject: [Omaha.pm] Meeting this Thr, 7pm! In-Reply-To: <200504192200.j3JM0rmD027033@omares-email.omnihotels.com> References: <200504192200.j3JM0rmD027033@omares-email.omnihotels.com> Message-ID: Jay: Great topic. /me checks the web site. Aha! Reboot the User. Thanks! Mat On Tue, 19 Apr 2005, Jay Hannah wrote: > > http://omaha.pm.org > > I'll be giving another ad-hoc presentation: > > J's OO Perl Practicum #2 > Converting procedural code to OO structures: How? And why? > 5 proprietary vendor data formats in 1 OO framework > Advantages, lessons learned, what could be better still, etc. > > j > > > _______________________________________________ > Omaha-pm mailing list > Omaha-pm@pm.org > http://mail.pm.org/mailman/listinfo/omaha-pm > From Jay at RebootTheUser.com Tue Apr 19 16:28:30 2005 From: Jay at RebootTheUser.com (Jay Swackhamer) Date: Tue Apr 19 16:29:28 2005 Subject: [Omaha.pm] Meeting this Thr, 7pm! In-Reply-To: References: <200504192200.j3JM0rmD027033@omares-email.omnihotels.com> Message-ID: <57108.68.96.22.160.1113953310.squirrel@webmail.reboottheuser.com> Side-Note..... It appears that I still have one Perl-Monger T-Shirt marked 'Mat Caughron' > Jay: > > Great topic. > > /me checks the web site. > > Aha! Reboot the User. Thanks! > > > > Mat > > > On Tue, 19 Apr 2005, Jay Hannah wrote: > >> >> http://omaha.pm.org >> >> I'll be giving another ad-hoc presentation: >> >> J's OO Perl Practicum #2 >> Converting procedural code to OO structures: How? And why? >> 5 proprietary vendor data formats in 1 OO framework >> Advantages, lessons learned, what could be better still, etc. >> >> j >> >> >> _______________________________________________ >> Omaha-pm mailing list >> Omaha-pm@pm.org >> http://mail.pm.org/mailman/listinfo/omaha-pm >> > _______________________________________________ > Omaha-pm mailing list > Omaha-pm@pm.org > http://mail.pm.org/mailman/listinfo/omaha-pm > -- Jay Swackhamer Reboot The User 15791 West Dodge Road Suite 135 Omaha, NE 68118 (402) 933-6449 (402) 933-6456 Fax http://www.RebootTheUser.com From jay at jays.net Tue Apr 19 16:38:41 2005 From: jay at jays.net (Jay Hannah) Date: Tue Apr 19 16:38:54 2005 Subject: [Omaha.pm] Automating Windows (DNS) with Perl Message-ID: <735d33641a4c00da93eb4b8d1b7ff86b@jays.net> Newsletter from O'Reilly UG Program, March 31. Stripped for Perl content only. j Begin forwarded message: > ***Automating Windows (DNS) with Perl > Perl is a fantastic tool for system administrators--even on Windows. > Though the shiny GUI is astonishingly useless (or at least too > mouse-friendly) for all but the simplest changes, there's plenty to > automate under the shell. Thomas Herchenroeder explains how he > wrapped dnscmd with Perl to make changes easily. > http://www.perl.com/pub/a/2005/03/24/perl_dns.html From jhannah at omnihotels.com Wed Apr 20 07:32:32 2005 From: jhannah at omnihotels.com (Jay Hannah) Date: Wed Apr 20 07:58:10 2005 Subject: [Omaha.pm] Testing Class::DBI Message-ID: <200504201432.j3KEWBmD014282@omares-email.omnihotels.com> http://planet.perl.org/ led me to http://use.perl.org/article.pl?sid=05/04/12/0231217&from=rss led me to http://24.213.86.123:8080/tpm/slides/2004_09_e/ Which is interesting CPAN stuff that does the same sort of things we're doing w/ our homegrown code. Score another point for the "when I wrote that why didn't I make it 100% reusable so I could upload it to CPAN?" angel on my shoulder. j From jay at jays.net Wed Apr 20 13:28:57 2005 From: jay at jays.net (Jay Hannah) Date: Wed Apr 20 13:29:11 2005 Subject: [Omaha.pm] Fwd: An Apology From Meetup.com Message-ID: <2631bf3de79a4eaf322c8046a1105720@jays.net> Anyone motivated to keep perl.meetup.com for Omaha? I'm not for $9/mo. I was barely motivated at $0/mo... -grin- Long live omaha.pm.org! It's not going away. Grin, j Begin forwarded message: > From: "Meetup.com" > Date: April 19, 2005 9:30:15 PM CDT > To: jay@jays.net > Subject: An Apology From Meetup.com > Reply-To: organizer@meetup.com > -------------- next part -------------- A non-text attachment was scrubbed... Name: logo_email.gif Type: image/gif Size: 2943 bytes Desc: not available Url : http://mail.pm.org/pipermail/omaha-pm/attachments/20050420/e2b30739/logo_email.gif -------------- next part -------------- > Tuesday April 19, 2005 > > > > Dear Organizer of The Omaha Perl Meetup Group-- > > As you may have heard, Meetup recently made an announcement you > probably don?t like: a required monthly group fee. > > We announced this a week ago, and we?ve heard the announcement was > abrupt, confusing, and inconsiderate of the hard work you do for your > groups ? for that we sincerely apologize. > > We also listened to that feedback and rewrote the announcement ? it > now reads as we wish it always had. We strongly encourage you to read > the new version (then please come back and read the rest of this email > ? it?ll only take a minute). > > www.meetup.com/changes > > Welcome back. By now you?ve read the announcement. Hopefully you?ve > paid the monthly fee for your group. If not, we hope this email > provides some useful information: > ? First, this isn?t a decision we made lightly. However, after > exploring every other possible path, we feel this is the only way to > ensure that Meetup.com is available for a long, long time so your > groups always have a home. > > ? Second, while we need to collect this monthly fee from each > Organizer, please remember this is a group fee. The financial burden > isn?t yours alone - the fee allows your group to use Meetup.com and > we encourage the group as a whole to contribute. > > We?ve also heard feedback that discussing money with your group may be > uncomfortable and/or you may not want to have to deal with collecting > and managing money. As with every new iteration of Meetup, we didn?t > get it perfect from the start. But as always we?re listening, we hear > this concern loud and clear, and we?ll respond as we always do ? by > making the improvements you want over time. > > ? Third, some people have been unclear about the price. If you > purchase in April, it costs $9/month until 2006. This special price is > our way of thanking you for being one of the first Organizers. > > ? Finally, we understand that some of you are waiting until the last > minute to make your first payment. You?re welcome to do that, however, > we?re now treating all purchases made in April, regardless of when > they?re made, as if they?re made on April 30. Don?t risk missing out > on the discounts ? sign up now. > > Hopefully this information has been useful and we hope you and your > group feel that Meetup.com is worth $9/month. If so, click the link > below to begin your subscription: > > https://secure.meetup.com/plus > > Sincerely, > ~The Team at Meetup.com > > ? > > You are receiving this message because you are?the Organizer of a > Meetup Group and have agreed to receive Meetup service announcements. > To review the Meetup Privacy Policy,?visit: > http://www.meetup.com/privacy/ From jhannah at omnihotels.com Wed Apr 20 15:08:15 2005 From: jhannah at omnihotels.com (Jay Hannah) Date: Wed Apr 20 15:08:11 2005 Subject: [Omaha.pm] Notes dump: pack, unpack, vec, and 2562 long bit vectors Message-ID: <200504202207.j3KM7rmD005054@omares-email.omnihotels.com> For the record... Here's a dump of notes/code from a day a couple weeks back I spent wrestling pack, unpack, vec, etc... I lost. Bad. I also stumped people on EFFNET #perl. -grin- j -------------- I have around 61M on/off switches (bits) I need to store in a database and do really fast lookups on. There's 7 bits per date (per other stuff), so we were thinking about having 1 row in the database for every calendar year (for each other stuff). So, stringing a whole year together (max 366 days) is a string of 2562 bits. Storing those 2562 bits as a long string of ASCII Ys and Ns or 1s and 0s would be easy. As would shrinking the column a bit by storing each day in hex (pretend there were 8 bits per date, then store "FF" in the database instead of "11111111"). For some reason, I'm thinking that storing the 2562 bits in binary in the database should be faster still, but so far my various benchmarking using pack, unpack, and vec is slightly slower than storing hex... ------ Benchmark: timing 1 iterations of byte, byte_onevec, char2562, char732... byte: 30 wallclock secs (11.82 usr + 7.92 sys = 19.74 CPU) @ 0.05/s (n=1) (warning: too few iterations for a reliable count) byte_onevec: 26 wallclock secs ( 8.35 usr + 7.02 sys = 15.37 CPU) @ 0.07/s (n=1) (warning: too few iterations for a reliable count) char2562: 34 wallclock secs (17.28 usr + 8.23 sys = 25.51 CPU) @ 0.04/s (n=1) (warning: too few iterations for a reliable count) char732: 13 wallclock secs ( 8.21 usr + 2.03 sys = 10.24 CPU) @ 0.10/s (n=1) (warning: too few iterations for a reliable count) --------- ./insert.pl #!/usr/bin/perl use Benchmark; #use DBI qw(:sql_types); #use DBD::Informix qw(:ix_types); use Omni::DB; use Bit::Vector; my $dbh = Omni::DB::connect_test_with_pw(); my $val1 = "1010101" x 366; substr $val1, 7 * 300, 7, "0011100"; my $val2 = "FF" x 366; substr $val2, 2 * 300, 2, "38"; use Omni::DB; my $val3 = pack("b2562", $val1); #my $strsql = "insert into jay (uni, char2562, char732, byte) values (?, ?, ?, ?)"; #my $sth = $dbh->prepare($strsql); #$sth->execute(1, $val1, $val2, $val3); #$dbh->commit; timethese(10, { 'char2562' => '@row = getrow("char2562"); die unless ((substr $row[0], 7 * 300, 7) eq "0011100")', 'char732' => '@row = getrow("char732"); die unless ((unpack("B7",pack("H2",(substr $row[0], 2 * 300, 2)))) eq "0011100")', 'byte' => '@row = getrow("byte"); die unless ((substr((unpack("b2562", $row[0])), 7 * 300, 7)) eq "0011100")' }); sub getrow { my ($what) = @_; my $strsql = "select $what from jay where uni = 1"; my $sth = $dbh->prepare($strsql); $sth->execute(); return $sth->fetchrow; } #print "@row\n"; $dbh->disconnect; ./j.pl use Test::More tests => 10; my $yn = "YNNYYNY"; $yn =~ tr/YN/10/; my $b = pack "b7", $yn; is((unpack "b7", $b), "1001101", "yay"); my $yn = "YNNYYNYY" x 366; substr $yn, 199 * 8, 8, "00001000"; substr $yn, 201 * 8, 8, "00010100"; $yn =~ tr/YN/10/; my $b = pack "b2928", $yn; is((substr((unpack "b2928", $b), 198 * 8, 8)), "10011011", "yay"); is((substr((unpack "b2928", $b), 199 * 8, 8)), "00001000", "yay"); is((substr((unpack "b2928", $b), 200 * 8, 8)), "10011011", "yay"); is((substr((unpack "b2928", $b), 201 * 8, 8)), "00010100", "yay"); is((substr((unpack "b2928", $b), 202 * 8, 8)), "10011011", "yay"); #is((unpack "b2928", (vec $b, (8 * 8 * 199), 8)), "10011011", "yay"); is((unpack "b2928", $b), $yn, "yay"); my $b = pack "b7", "0" x 8; vec($b,0,1) = 0; is((unpack "b7", $b), "0000000", "yay"); vec($b,0,1) = 1; is((unpack "b7", $b), "1000000", "yay"); vec($b,0,2) = 2; is((unpack "b7", $b), "0100000", "yay"); vec($b,0,2) = 3; is((unpack "b7", $b), "1100000", "yay"); vec($b,0,2) = 5; is((unpack "b7", $b), "1000000", "yay"); vec($b,0,4) = 5; is((unpack "b7", $b), "1010000", "yay"); ./load_jay.pl #!usr/bin/perl use strict; use Omni::DB; my $dbh = Omni::DB::connect_test_with_pw; my $val1 = "1010101" x 366; substr $val1, 7 * 300, 7, "0011100"; push @vals,$val1; my $val2 = "FF" x 366; substr $val2, 2 * 300, 2, "38"; push @vals,$val2; my $val3 = pack("b2562", $val1); push @vals,$val3; my $all=0; my $ctr=0; foreach my $table qw(jay_char2562 jay_char732 jay_byte) { for (1..10000) { my $strsql = "insert into $table (uni,string) values (?,?)"; my $sth = $dbh->prepare($strsql); $sth->execute(0, $vals[$ctr]); $dbh->commit; print "$table $all\n" if ($all % 1000 == 0); $all++; } $ctr++; } $dbh->disconnect; ./j2.pl use Test::More tests => 10; my $yn = "YNNYYNY"; $yn =~ tr/YN/10/; my $b = pack "b7", $yn; is((unpack "b7", $b), "1001101", "yay"); my $yn = "YNNYYNYY" x 366; substr $yn, 199 * 8, 8, "00001000"; substr $yn, 201 * 8, 8, "00010100"; $yn =~ tr/YN/10/; my $b; for (0..7) { vec $b, $_, 1 = substr for (0..7) { print vec $b, $_, 1; } print "\n"; #is((vec $b, 0, 8), "10011011", "yay"); #is((vec $b, 198 * 8, 8), "10011011", "yay"); #is((unpack "b2928", (vec $b, (8 * 8 * 199), 8)), "10011011", "yay"); #is((unpack "b2928", $b), $yn, "yay"); my $b = pack "b7", "0" x 8; vec($b,0,1) = 0; is((unpack "b7", $b), "0000000", "yay"); vec($b,0,1) = 1; is((unpack "b7", $b), "1000000", "yay"); vec($b,0,2) = 2; is((unpack "b7", $b), "0100000", "yay"); vec($b,0,2) = 3; is((unpack "b7", $b), "1100000", "yay"); vec($b,0,2) = 5; is((unpack "b7", $b), "1000000", "yay"); vec($b,0,4) = 5; is((unpack "b7", $b), "1010000", "yay"); ./j3.pl use strict; # For each day of a year, I have 7 bits to track. # There are up to 366 days in a year. # So, a year in one string of bits might look something like this: my $str = "0001010" x 366; # So as one big bitstring: my $bitstring = pack "b2562", $str; # This gets me back to the original: print join "", unpack("b2562", $bitstring); print "\n"; my $day300; for (0 .. 6) { $day300 .= vec $bitstring, 7 * 299 + $_, 1; } print "$day300\n"; ./j4.pl use Benchmark; my $val = "10101010" x 366; substr $val, 8 * 300, 8, "01100001"; my $bs = pack "b2928", $val; timethese(1000, { looper => 'looper()', onevec => 'onevec()', }); sub looper { my $ret; for (0..7) { $ret .= vec $bs, 300 * 8 + $_, 1; } die $ret unless ($ret eq "01100001"); } sub onevec { my $ret; $ret = vec $bs, 366 * 8 - 300, 8; $ret = reverse(unpack "b8", $ret); die $ret unless ($ret eq "01100001"); } ./read.pl use Omni::DB; use Benchmark; my $dbh = Omni::DB::connect_test_with_pw; my $val1 = "10101010" x 366; substr $val1, 8 * 300, 8, "00100000"; push @vals,$val1; my $val2 = "AA" x 366; substr $val2, 2 * 300, 2, "20"; push @vals,$val2; my $val3 = pack("b2562", $val1); push @vals,$val3; timethese(1, { 'char2562' => 'read_char2562', 'char732' => 'read_char732', 'byte' => 'read_byte', 'byte_onevec' => 'read_byte_onevec', }); sub read_char2562 { my $strsql = "select * from jay_char2562"; my $sth = $dbh->prepare($strsql); $sth->execute; while (@row = $sth->fetchrow) { my $val = substr $row[1], 8 * 299, 8; #die $val unless ($val eq "10101010"); $val = substr $row[1], 8 * 300, 8; #die $val unless ($val eq "00100000"); } $sth->finish; } sub read_char732 { my $strsql = "select * from jay_char732"; my $sth = $dbh->prepare($strsql); $sth->execute; while (@row = $sth->fetchrow) { my $val = unpack("B8",pack("H2",(substr $row[1], 2 * 299, 2))); #die $val unless ($val eq "10101010"); my $val = unpack("B8",pack("H2",(substr $row[1], 2 * 300, 2))); #die $val unless ($val eq "00100000"); } $sth->finish; } sub read_byte { my $strsql = "select * from jay_byte"; my $sth = $dbh->prepare($strsql); $sth->execute; while (@row = $sth->fetchrow) { my $val; for (0..6) { $val .= vec $row[1], 299 * 8 + $_, 1; } #die $val unless ($val eq "10101010"); $val = ''; for (0..6) { $val .= vec $row[1], 300 * 8 + $_, 1; } #die $val unless ($val eq "00100000"); } $sth->finish; } sub read_byte_onevec { my $strsql = "select * from jay_byte"; my $sth = $dbh->prepare($strsql); $sth->execute; while (@row = $sth->fetchrow) { $ret = vec $bs, 366 * 8 - 300, 8; $ret = reverse(unpack "b8", $ret); #die $ret unless ($ret eq "10101010"); $ret = vec $bs, 366 * 8 - 300, 8; $ret = reverse(unpack "b8", $ret); #die $ret unless ($ret eq "00100000"); } } __END__ 'char2562' => '@row = getrow("char2562"); die unless ((substr $row[0], 7 * 300, 7) eq "0011100")', 'char732' => '@row = getrow("char732"); die unless ((unpack("B7",pack("H2",(substr $row[0], 2 * 300, 2)))) eq "0011100")', 'byte' => '@row = getrow("byte"); die unless ((substr((unpack("b2562", $row[0])), 7 * 300, 7)) eq "0011100")' ./j5.pl $z = "11101100"x300; substr( $z, 0, 8 ) = "01100000"; $z = pack "b2400", $z; print vec $z, 0, 8; # That prints '6' print "\n\n"; $z = "11101100"x300; substr( $z, 8, 8 ) = "01100000"; z = pack "b2400", $z; print vec $z, 8, 8; # That prints '55' print "\n\n"; ./j6.pl $bs = "00100000" x 366; #substr $bs, 300 * 8, 8, "01000001"; $bv = pack "b*", $bs; $subvec = vec($bv, 0, 8); printf("%08b\n", $subvec); ./c.pl use IO::File; my $fh = IO::File->new("< c"); print join "\n", map /^(\w+):([^\n]+).*$/o, <$fh>; From jay at jays.net Thu Apr 21 04:32:50 2005 From: jay at jays.net (Jay Hannah) Date: Thu Apr 21 04:33:02 2005 Subject: [Omaha.pm] Perl, PHP UG Battle Royale and/or Share the Love In-Reply-To: References: <1735ba47d40fb150c1114622fe56f84e@jays.net> Message-ID: On Feb 19, 2005, at 9:53 PM, Mat Caughron wrote: > Dear Omaha Perl Addicts: > > Thought you all might find this useful/interesting as I do: > http://www.cs.wcupa.edu/%7Erkline/perl2php/ > > Also, maybe one of these months we could have the PHP and Perl > get-to-gether occur at the same time/place. Add wireless network. > Hilarity ensues. How about next month? Let's have a code-off! Somebody (who must recuse themselves from the contest) picks a small programming task/challenge and its a battle Royale (w/ cheese) of the languages...? The winner is whoevers code looks more like Perl! (kidding!) - Pick a date. PM is typically 3rd Thursday, but whatever works is fine w/ me. - @ Reboot the User? Somewhere else? (I'm going to be out of country June 15-28 so let's try to avoid that...) Once we pick a date I can get a camel/cuckoo on OLUG.org again... ( Wow... The cuckoo is an evil bird! http://www.oreilly.com/catalog/progphp/colophon.html All camels do is spit on people. And bite them. -grin- ) j Perl UG: http://omaha.pm.org PHP UG: http://omaha.phpconsulting.com/ From scott.l.miller at hp.com Thu Apr 21 06:47:47 2005 From: scott.l.miller at hp.com (Miller, Scott L (Omaha Networks)) Date: Thu Apr 21 06:47:57 2005 Subject: [Omaha.pm] Notes dump: pack, unpack, vec, and 2562 long bit vectors Message-ID: <1F7C0C8F4BD7C54A8BC55012FEF3DF6D0302E8C2@omaexc11.americas.cpqcorp.net> Hmm, I can't help but wonder if you're not solving the wrong problem. This seems awfully convoluted. So exactly what are these 7 bits per date used for, and why do you have to keep many years of information? Is the actual data being stored as repetitive as your example? I'm hoping not... -Scott -----Original Message----- From: omaha-pm-bounces@pm.org [mailto:omaha-pm-bounces@pm.org]On Behalf Of Jay Hannah Sent: Wednesday, April 20, 2005 5:08 PM To: omaha-pm@pm.org Subject: [Omaha.pm] Notes dump: pack, unpack, vec, and 2562 long bit vectors For the record... Here's a dump of notes/code from a day a couple weeks back I spent wrestling pack, unpack, vec, etc... I lost. Bad. I also stumped people on EFFNET #perl. -grin- j -------------- I have around 61M on/off switches (bits) I need to store in a database and do really fast lookups on. There's 7 bits per date (per other stuff), so we were thinking about having 1 row in the database for every calendar year (for each other stuff). So, stringing a whole year together (max 366 days) is a string of 2562 bits. Storing those 2562 bits as a long string of ASCII Ys and Ns or 1s and 0s would be easy. As would shrinking the column a bit by storing each day in hex (pretend there were 8 bits per date, then store "FF" in the database instead of "11111111"). For some reason, I'm thinking that storing the 2562 bits in binary in the database should be faster still, but so far my various benchmarking using pack, unpack, and vec is slightly slower than storing hex... ------ Benchmark: timing 1 iterations of byte, byte_onevec, char2562, char732... byte: 30 wallclock secs (11.82 usr + 7.92 sys = 19.74 CPU) @ 0.05/s (n=1) (warning: too few iterations for a reliable count) byte_onevec: 26 wallclock secs ( 8.35 usr + 7.02 sys = 15.37 CPU) @ 0.07/s (n=1) (warning: too few iterations for a reliable count) char2562: 34 wallclock secs (17.28 usr + 8.23 sys = 25.51 CPU) @ 0.04/s (n=1) (warning: too few iterations for a reliable count) char732: 13 wallclock secs ( 8.21 usr + 2.03 sys = 10.24 CPU) @ 0.10/s (n=1) (warning: too few iterations for a reliable count) --------- ./insert.pl #!/usr/bin/perl use Benchmark; #use DBI qw(:sql_types); #use DBD::Informix qw(:ix_types); use Omni::DB; use Bit::Vector; my $dbh = Omni::DB::connect_test_with_pw(); my $val1 = "1010101" x 366; substr $val1, 7 * 300, 7, "0011100"; my $val2 = "FF" x 366; substr $val2, 2 * 300, 2, "38"; use Omni::DB; my $val3 = pack("b2562", $val1); #my $strsql = "insert into jay (uni, char2562, char732, byte) values (?, ?, ?, ?)"; #my $sth = $dbh->prepare($strsql); #$sth->execute(1, $val1, $val2, $val3); #$dbh->commit; timethese(10, { 'char2562' => '@row = getrow("char2562"); die unless ((substr $row[0], 7 * 300, 7) eq "0011100")', 'char732' => '@row = getrow("char732"); die unless ((unpack("B7",pack("H2",(substr $row[0], 2 * 300, 2)))) eq "0011100")', 'byte' => '@row = getrow("byte"); die unless ((substr((unpack("b2562", $row[0])), 7 * 300, 7)) eq "0011100")' }); sub getrow { my ($what) = @_; my $strsql = "select $what from jay where uni = 1"; my $sth = $dbh->prepare($strsql); $sth->execute(); return $sth->fetchrow; } #print "@row\n"; $dbh->disconnect; ./j.pl use Test::More tests => 10; my $yn = "YNNYYNY"; $yn =~ tr/YN/10/; my $b = pack "b7", $yn; is((unpack "b7", $b), "1001101", "yay"); my $yn = "YNNYYNYY" x 366; substr $yn, 199 * 8, 8, "00001000"; substr $yn, 201 * 8, 8, "00010100"; $yn =~ tr/YN/10/; my $b = pack "b2928", $yn; is((substr((unpack "b2928", $b), 198 * 8, 8)), "10011011", "yay"); is((substr((unpack "b2928", $b), 199 * 8, 8)), "00001000", "yay"); is((substr((unpack "b2928", $b), 200 * 8, 8)), "10011011", "yay"); is((substr((unpack "b2928", $b), 201 * 8, 8)), "00010100", "yay"); is((substr((unpack "b2928", $b), 202 * 8, 8)), "10011011", "yay"); #is((unpack "b2928", (vec $b, (8 * 8 * 199), 8)), "10011011", "yay"); is((unpack "b2928", $b), $yn, "yay"); my $b = pack "b7", "0" x 8; vec($b,0,1) = 0; is((unpack "b7", $b), "0000000", "yay"); vec($b,0,1) = 1; is((unpack "b7", $b), "1000000", "yay"); vec($b,0,2) = 2; is((unpack "b7", $b), "0100000", "yay"); vec($b,0,2) = 3; is((unpack "b7", $b), "1100000", "yay"); vec($b,0,2) = 5; is((unpack "b7", $b), "1000000", "yay"); vec($b,0,4) = 5; is((unpack "b7", $b), "1010000", "yay"); ./load_jay.pl #!usr/bin/perl use strict; use Omni::DB; my $dbh = Omni::DB::connect_test_with_pw; my $val1 = "1010101" x 366; substr $val1, 7 * 300, 7, "0011100"; push @vals,$val1; my $val2 = "FF" x 366; substr $val2, 2 * 300, 2, "38"; push @vals,$val2; my $val3 = pack("b2562", $val1); push @vals,$val3; my $all=0; my $ctr=0; foreach my $table qw(jay_char2562 jay_char732 jay_byte) { for (1..10000) { my $strsql = "insert into $table (uni,string) values (?,?)"; my $sth = $dbh->prepare($strsql); $sth->execute(0, $vals[$ctr]); $dbh->commit; print "$table $all\n" if ($all % 1000 == 0); $all++; } $ctr++; } $dbh->disconnect; ./j2.pl use Test::More tests => 10; my $yn = "YNNYYNY"; $yn =~ tr/YN/10/; my $b = pack "b7", $yn; is((unpack "b7", $b), "1001101", "yay"); my $yn = "YNNYYNYY" x 366; substr $yn, 199 * 8, 8, "00001000"; substr $yn, 201 * 8, 8, "00010100"; $yn =~ tr/YN/10/; my $b; for (0..7) { vec $b, $_, 1 = substr for (0..7) { print vec $b, $_, 1; } print "\n"; #is((vec $b, 0, 8), "10011011", "yay"); #is((vec $b, 198 * 8, 8), "10011011", "yay"); #is((unpack "b2928", (vec $b, (8 * 8 * 199), 8)), "10011011", "yay"); #is((unpack "b2928", $b), $yn, "yay"); my $b = pack "b7", "0" x 8; vec($b,0,1) = 0; is((unpack "b7", $b), "0000000", "yay"); vec($b,0,1) = 1; is((unpack "b7", $b), "1000000", "yay"); vec($b,0,2) = 2; is((unpack "b7", $b), "0100000", "yay"); vec($b,0,2) = 3; is((unpack "b7", $b), "1100000", "yay"); vec($b,0,2) = 5; is((unpack "b7", $b), "1000000", "yay"); vec($b,0,4) = 5; is((unpack "b7", $b), "1010000", "yay"); ./j3.pl use strict; # For each day of a year, I have 7 bits to track. # There are up to 366 days in a year. # So, a year in one string of bits might look something like this: my $str = "0001010" x 366; # So as one big bitstring: my $bitstring = pack "b2562", $str; # This gets me back to the original: print join "", unpack("b2562", $bitstring); print "\n"; my $day300; for (0 .. 6) { $day300 .= vec $bitstring, 7 * 299 + $_, 1; } print "$day300\n"; ./j4.pl use Benchmark; my $val = "10101010" x 366; substr $val, 8 * 300, 8, "01100001"; my $bs = pack "b2928", $val; timethese(1000, { looper => 'looper()', onevec => 'onevec()', }); sub looper { my $ret; for (0..7) { $ret .= vec $bs, 300 * 8 + $_, 1; } die $ret unless ($ret eq "01100001"); } sub onevec { my $ret; $ret = vec $bs, 366 * 8 - 300, 8; $ret = reverse(unpack "b8", $ret); die $ret unless ($ret eq "01100001"); } ./read.pl use Omni::DB; use Benchmark; my $dbh = Omni::DB::connect_test_with_pw; my $val1 = "10101010" x 366; substr $val1, 8 * 300, 8, "00100000"; push @vals,$val1; my $val2 = "AA" x 366; substr $val2, 2 * 300, 2, "20"; push @vals,$val2; my $val3 = pack("b2562", $val1); push @vals,$val3; timethese(1, { 'char2562' => 'read_char2562', 'char732' => 'read_char732', 'byte' => 'read_byte', 'byte_onevec' => 'read_byte_onevec', }); sub read_char2562 { my $strsql = "select * from jay_char2562"; my $sth = $dbh->prepare($strsql); $sth->execute; while (@row = $sth->fetchrow) { my $val = substr $row[1], 8 * 299, 8; #die $val unless ($val eq "10101010"); $val = substr $row[1], 8 * 300, 8; #die $val unless ($val eq "00100000"); } $sth->finish; } sub read_char732 { my $strsql = "select * from jay_char732"; my $sth = $dbh->prepare($strsql); $sth->execute; while (@row = $sth->fetchrow) { my $val = unpack("B8",pack("H2",(substr $row[1], 2 * 299, 2))); #die $val unless ($val eq "10101010"); my $val = unpack("B8",pack("H2",(substr $row[1], 2 * 300, 2))); #die $val unless ($val eq "00100000"); } $sth->finish; } sub read_byte { my $strsql = "select * from jay_byte"; my $sth = $dbh->prepare($strsql); $sth->execute; while (@row = $sth->fetchrow) { my $val; for (0..6) { $val .= vec $row[1], 299 * 8 + $_, 1; } #die $val unless ($val eq "10101010"); $val = ''; for (0..6) { $val .= vec $row[1], 300 * 8 + $_, 1; } #die $val unless ($val eq "00100000"); } $sth->finish; } sub read_byte_onevec { my $strsql = "select * from jay_byte"; my $sth = $dbh->prepare($strsql); $sth->execute; while (@row = $sth->fetchrow) { $ret = vec $bs, 366 * 8 - 300, 8; $ret = reverse(unpack "b8", $ret); #die $ret unless ($ret eq "10101010"); $ret = vec $bs, 366 * 8 - 300, 8; $ret = reverse(unpack "b8", $ret); #die $ret unless ($ret eq "00100000"); } } __END__ 'char2562' => '@row = getrow("char2562"); die unless ((substr $row[0], 7 * 300, 7) eq "0011100")', 'char732' => '@row = getrow("char732"); die unless ((unpack("B7",pack("H2",(substr $row[0], 2 * 300, 2)))) eq "0011100")', 'byte' => '@row = getrow("byte"); die unless ((substr((unpack("b2562", $row[0])), 7 * 300, 7)) eq "0011100")' ./j5.pl $z = "11101100"x300; substr( $z, 0, 8 ) = "01100000"; $z = pack "b2400", $z; print vec $z, 0, 8; # That prints '6' print "\n\n"; $z = "11101100"x300; substr( $z, 8, 8 ) = "01100000"; z = pack "b2400", $z; print vec $z, 8, 8; # That prints '55' print "\n\n"; ./j6.pl $bs = "00100000" x 366; #substr $bs, 300 * 8, 8, "01000001"; $bv = pack "b*", $bs; $subvec = vec($bv, 0, 8); printf("%08b\n", $subvec); ./c.pl use IO::File; my $fh = IO::File->new("< c"); print join "\n", map /^(\w+):([^\n]+).*$/o, <$fh>; _______________________________________________ Omaha-pm mailing list Omaha-pm@pm.org http://mail.pm.org/mailman/listinfo/omaha-pm From jay at jays.net Thu Apr 21 11:07:48 2005 From: jay at jays.net (Jay Hannah) Date: Thu Apr 21 11:07:59 2005 Subject: [Omaha.pm] Notes dump: pack, unpack, vec, and 2562 long bit vectors In-Reply-To: <1F7C0C8F4BD7C54A8BC55012FEF3DF6D0302E8C2@omaexc11.americas.cpqcorp.net> References: <1F7C0C8F4BD7C54A8BC55012FEF3DF6D0302E8C2@omaexc11.americas.cpqcorp.net> Message-ID: On Apr 21, 2005, at 8:47 AM, Miller, Scott L (Omaha Networks) wrote: > Hmm, I can't help but wonder if you're not solving the wrong problem. > This seems awfully convoluted. So exactly what are these 7 bits per > date used for, and why do you have to keep many years of information? > > Is the actual data being stored as repetitive as your example? I'm > hoping not... Long story. Are you coming to the meeting tonight? http://omaha.pm.org j From dan at linder.org Thu Apr 21 11:36:40 2005 From: dan at linder.org (Daniel Linder) Date: Thu Apr 21 11:36:15 2005 Subject: [Omaha.pm] Notes dump: pack, unpack, vec, and 2562 long bit vectors In-Reply-To: <200504202207.j3KM7rmD005054@omares-email.omnihotels.com> References: <200504202207.j3KM7rmD005054@omares-email.omnihotels.com> Message-ID: <32499.12.160.138.57.1114108600.squirrel@12.160.138.57> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 > Benchmark: timing 1 iterations of byte, byte_onevec, char2562, char732... > byte: 30 wallclock secs (11.82 usr + 7.92 sys = 19.74 CPU) @ > 0.05/s (n=1) > > byte_onevec: 26 wallclock secs ( 8.35 usr + 7.02 sys = 15.37 CPU) @ > 0.07/s (n=1) > > char2562: 34 wallclock secs (17.28 usr + 8.23 sys = 25.51 CPU) @ > 0.04/s (n=1) > > char732: 13 wallclock secs ( 8.21 usr + 2.03 sys = 10.24 CPU) @ > 0.10/s (n=1) Jay, I noticed your timings included actual DB inserts. If you re-ran this with everything up to the actual "execute" command, did that make much of a difference in speed? If the test then equalized, it could be that the network and/or DB was experiencing a bit of lag or other load during the specific tests. I'm just shooting in the dark -- you seem to have this testing thing pretty well under control... :) As a side note, I played with pack/unpack for the first time to experient a bit. I was wondering if you had tried playing with packing the 1's and 0's into a base-128 ("w") encoding? I was trying to see if there was a direct "string of 1's/0's to binary vector" function...probably the "vec" function. Dan - - - - - "I do not fear computer, I fear the lack of them." -- Isaac Asimov GPG fingerprint:9EE8 ABAE 10D3 0B55 C536 E17A 3620 4DCA A533 19BF -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQFCZ/K4NiBNyqUzGb8RAvigAJ42e4PVvJaOL/VKYp9xSpK6VmLUrQCbBK64 rPoJhPCEKWFBPdTyWhtfD/g= =9m62 -----END PGP SIGNATURE----- From scott.l.miller at hp.com Thu Apr 21 12:52:22 2005 From: scott.l.miller at hp.com (Miller, Scott L (Omaha Networks)) Date: Thu Apr 21 12:53:07 2005 Subject: [Omaha.pm] Notes dump: pack, unpack, vec, and 2562 long bit vectors Message-ID: <1F7C0C8F4BD7C54A8BC55012FEF3DF6D0302E8C4@omaexc11.americas.cpqcorp.net> No, It's our end of bowling season prize money night :-) I'm definitely looking forward to attending next months meeting though. -Scott -----Original Message----- From: omaha-pm-bounces@pm.org [mailto:omaha-pm-bounces@pm.org]On Behalf Of Jay Hannah Sent: Thursday, April 21, 2005 1:08 PM To: Perl Mongers of Omaha, Nebraska USA Subject: Re: [Omaha.pm] Notes dump: pack, unpack, vec,and 2562 long bit vectors On Apr 21, 2005, at 8:47 AM, Miller, Scott L (Omaha Networks) wrote: > Hmm, I can't help but wonder if you're not solving the wrong problem. > This seems awfully convoluted. So exactly what are these 7 bits per > date used for, and why do you have to keep many years of information? > > Is the actual data being stored as repetitive as your example? I'm > hoping not... Long story. Are you coming to the meeting tonight? http://omaha.pm.org j _______________________________________________ Omaha-pm mailing list Omaha-pm@pm.org http://mail.pm.org/mailman/listinfo/omaha-pm From jay at jays.net Tue Apr 26 20:26:12 2005 From: jay at jays.net (Jay Hannah) Date: Tue Apr 26 20:26:27 2005 Subject: [Omaha.pm] Fwd: Apress Perl User Groups Message-ID: <8e89851cb8e12f6633c6f515a2741e3d@jays.net> From: "Janet Crosbie" Date: February 11, 2005 4:24:39 PM CST To: "Janet Crosbie" Cc: "Julie Miller" Subject: Apress Perl User Groups Dear Perl Monger, ? Thanks again for recently registering your group with Apress. We?work proactively on behalf of all registered user groups. For example, we are happy to sponsor group events and parties with books and T-shirts. And when groups request a local author to speak at a meeting, Apress tries to fill the request. ? ? Similarly, user groups are incredibly valuable and helpful to Apress, because they help spread the word about what Apress is and what Apress does. Example: when I update one contact person about Apress happenings, I simultaneously reach many people, by word of mouth among the group. ? In the past year we?ve published 3 essential Perl titles, including: ? ? Perl 6 Now (http://www.apress.com/book/bookDisplay.html?bID=355), ? Randal Schwartz?s Perls of Wisdom (http://www.apress.com/book/bookDisplay.html?bID=307), ? Beginning Perl, Second Edition ((http://www.apress.com/book/bookDisplay.html?bID=344) ? And throughout 2005, we?ll continue to publish titles that are crucial to your continuing Perl education, like: ? ? Pro Perl (http://www.apress.com/book/bookDisplay.html?bID=392), ? Pro Perl Debugging (http://www.apress.com/book/bookDisplay.html?bID=399), ? Pro Perl Parsing (http://www.apress.com/book/bookDisplay.html?bID=432) ? We?ll be happy to send you copies of these books to review and to give away as meeting prizes. In return, we simply encourage all book winners to write a thoughtful review, and post it to a favorite site or blog. ? Book reviews enhance discussion at group meetings and bolster content on group websites. We?ve posted review suggestions onto our website, and you?re welcome to link them to your own site (http://www.apress.com/userGroups/writeareview.html). And please let me know if you?d like to post our company logo on your site. ? For your meetings, we?re happy to provide additional Apress freebies like T-shirts, sampler CDs, roadmaps, and title lists. And year-round, groups can take advantage of a 25%-off discount on all current Apress titles. ? Please contact me directly if you have questions or ideas, and I look forward to working with you this year! ? Sincerely, Janet Crosbie ------------------ Janet Crosbie User Group Liaison Apress 2560 Ninth Street, Suite 219 Berkeley, CA 94710 510-549-5930 ext.121 phone 510-549-5939 fax janet@apress.com www.apress.com ?