From jhannah at omnihotels.com Tue Jan 9 08:37:10 2007 From: jhannah at omnihotels.com (Jay Hannah) Date: Tue, 9 Jan 2007 10:37:10 -0600 Subject: [Omaha.pm] Wow. $/ = '\00'; (and secret meeting tonight) Message-ID: Have I freaked out lately about how cool Perl is? This morning I was sent data like this: -------------------------- 01/03/07 11:12:57: Type B msg to HRS, ars=AA, hrs=OM, msg # 280259B8FB9DE4 HDRB|ARSAA|HRSOM|AADHDQRM|CTYOMA|SCTHDQ|SGAAA|SFFIC33/99999999|GMT031112 |\ 7JAN07|OTD18JAN07|NNT1|NPR1|NRM1|PID15981|RMR135.00|CURUSD|RTYXDRVOP|SIN R\ Q NON SMK RM.KING BD||GUEST|NAD1|NAMKRD F||\00 01/03/07 14:42:31: Type B msg to HRS, ars=UA, hrs=OM, msg # 281F59BC0D7F57 BM|SINNSRM||GUEST|NAD1|NAMPXXXXXXXXXXXXI|NNA1|NNMPAXXXXXXXXXXXXXXXAS|AD1 A\ MERICAN EXPRESS\r\n8415 DATAPOINT XXXXXX XXXXXXXX\r\nSAN ANTONIO TX 78229\ USA||FLIGHT|TXTAA330S04JAN DFWIAH HK1/0830P 0935P||\00 01/03/07 21:10:30: Type B msg to HRS, ars=AA, hrs=OM, msg # 280259C1BC65AF HRSREJ|TXT\r\n at QP OMAOMHL\r\n.HDQRMAA 032110\r\n at AVH\r\n \ \r\nOM576875,935259,396345 \ \r\n ASSIGNED \r\n FOR \ \r\n||\00 -------------------------- And Perl just eats it up... $/ = '\00'; open (IN, "log"); while () { s/\\\n//g; my ($act) = /\|ACT(\w+)/; my ($cnf) = /\|CNF(\w+)/; print "[$act][$cnf]\n"; } close IN; Unreal. Incidentally, out secret monthly meeting is tonight. It's a secret, so don't tell anybody. http://omaha.pm.org :) j From jay at jays.net Tue Jan 9 09:09:54 2007 From: jay at jays.net (Jay Hannah) Date: Tue, 9 Jan 2007 11:09:54 -0600 (CST) Subject: [Omaha.pm] Wow. $/ = '\00'; (and secret meeting tonight) In-Reply-To: References: Message-ID: On Tue, 9 Jan 2007, Jay Hannah wrote: > This morning I was sent data like this: -sigh- And here's what that looks like when I don't use Outlook. 01/03/07 11:12:57: Type B msg to HRS, ars=AA, hrs=OM, msg # 280259B8FB9DE4 HDRB|ARSAA|HRSOM|AADHDQRM|CTYOMA|SCTHDQ|SGAAA|SFFIC33/99999999|GMT031112|\ 7JAN07|OTD18JAN07|NNT1|NPR1|NRM1|PID15981|RMR135.00|CURUSD|RTYXDRVOP|SINR\ Q NON SMK RM.KING BD||GUEST|NAD1|NAMKRD F||\00 01/03/07 14:42:31: Type B msg to HRS, ars=UA, hrs=OM, msg # 281F59BC0D7F57 BM|SINNSRM||GUEST|NAD1|NAMPXXXXXXXXXXXXI|NNA1|NNMPAXXXXXXXXXXXXXXXAS|AD1A\ MERICAN EXPRESS\r\n8415 DATAPOINT XXXXXX XXXXXXXX\r\nSAN ANTONIO TX 78229\ USA||FLIGHT|TXTAA330S04JAN DFWIAH HK1/0830P 0935P||\00 01/03/07 21:10:30: Type B msg to HRS, ars=AA, hrs=OM, msg # 280259C1BC65AF HRSREJ|TXT\r\n at QP OMAOMHL\r\n.HDQRMAA 032110\r\n at AVH\r\n \ \r\nOM576875,935259,396345 \ \r\n ASSIGNED \r\n FOR \ \r\n||\00 Ever so slightly less ugly. :) j From jay at jays.net Tue Jan 9 22:10:57 2007 From: jay at jays.net (Jay Hannah) Date: Wed, 10 Jan 2007 00:10:57 -0600 Subject: [Omaha.pm] Record setting mtg Message-ID: <980e0156a0e06a949dabc538e49c8a23@jays.net> Wow. 6 mongers and 3 innocent bystanders. That's more attendance than usual. Perhaps if we make them *super* secret meetings 10 people will show up? :) Jay, Chris, Brandon, Kiran, Mark, Mike... Sounds like a quorum to me. Here's the Expect.pm stuff I was talking about: http://omaha.pm.org/presentations/pscrawl_pl.txt http://search.cpan.org/~rgiersig/Expect-1.20/Expect.pod Sorry about the distractions. No rest for the wicked. j From jhannah at omnihotels.com Wed Jan 10 11:48:50 2007 From: jhannah at omnihotels.com (Jay Hannah) Date: Wed, 10 Jan 2007 13:48:50 -0600 Subject: [Omaha.pm] Taunting Java Message-ID: LOL... Looks like I added that Java stab back in 2003... Damn I'm a funny guy. :) j use Test::More tests => 70; use Model::t::HashTest; my $hash = new Model::t::HashTest; # Test adding scalar keys... ok(defined $hash, '$hash defined'); ok($hash->add('A', 'Apple'), '$hash->A added'); is($hash->A, 'Apple', '$hash->A returns Apple'); ok($hash->add(B, 'Barnyard'), '$hash->B added'); is($hash->B, 'Barnyard', '$hash->B returns Barnyard'); is($hash->A, 'Apple', '$hash->A is still Apple'); # Test overwrite... ok($hash->add('A', 'Adam'), '$hash->A overwritten w/ Adam'); is($hash->B, 'Barnyard', '$hash->B returns Barnyard'); is($hash->A, 'Adam', '$hash->A returns Adam'); ok($hash->add('A', 'Apple'), '$hash->A overwritten w/ Apple'); is($hash->B, 'Barnyard', '$hash->B returns Barnyard'); is($hash->A, 'Apple', '$hash->A returns Apple'); # -------------------------------------------- # Test adding a key that is an object... # -------------------------------------------- package Ping; # Try this, Java! sub ping { return "pong"; } sub new { return bless {} } package main; my $ping = new Ping; ok(defined $ping, '$ping defined'); ok($ping->ping eq "pong", '$ping->ping passed'); ok($hash->add('Ping', $ping), '$hash->$ping added'); ok($hash->Ping->ping eq "pong", '$hash->Ping->ping is pong'); ok($hash->A eq 'Apple', '$hash->A is still Apple'); ok($hash->B eq 'Barnyard', '$hash->B is still Barnyard'); # -------------------------------------------- ...etc... $ perl Hash.t 1..70 ok 1 - $hash defined ok 2 - $hash->A added ok 3 - $hash->A returns Apple ok 4 - $hash->B added ok 5 - $hash->B returns Barnyard ok 6 - $hash->A is still Apple ok 7 - $hash->A overwritten w/ Adam ok 8 - $hash->B returns Barnyard ok 9 - $hash->A returns Adam ok 10 - $hash->A overwritten w/ Apple ok 11 - $hash->B returns Barnyard ok 12 - $hash->A returns Apple ok 13 - $ping defined ok 14 - $ping->ping passed ok 15 - $hash->$ping added ok 16 - $hash->Ping->ping is pong ok 17 - $hash->A is still Apple ok 18 - $hash->B is still Barnyard ...etc... From jay at jays.net Thu Jan 11 05:51:16 2007 From: jay at jays.net (Jay Hannah) Date: Thu, 11 Jan 2007 07:51:16 -0600 Subject: [Omaha.pm] requesting quick help References: <4DDFD9DB-AA66-4646-8C10-89821458A5B4@jays.net> Message-ID: <189A688A-C30A-4537-84C4-2AEA07046621@jays.net> [Hmmm... Weird. Cox didn't forward this to the pm.org server? Let's try again using my smtp server so I can debug...] From: Jay Hannah Date: January 10, 2007 9:11:30 PM CST To: kiran bina Cc: Nebraska USA Perl Mongers of Omaha Subject: Re: requesting quick help (1) You've got a "sleep 1" on line 44 slowing you down. :) (2) Given your filename list Org1_Org2.common Org1-Org2-Org3.A_unique Org1_Org2_Org3.common Org1_Org3.common Org2-Org1-Org3.B_unique Org2_Org3.common Org3-Org1-Org2.C_unique In this block of code if($fileName =~ /\.BC98/ || $fileName =~ /\.BC90/ || $fileName =~ /B_Unique/ || $fileName =~ /Org2_Org3.common/ || $fileName =~ /Org2- Org1-Org3.B_unique/) { print " 1 Searching file: $file_names[0]"; @file_names = ($file_names[0]); # ATC } elsif($fileName =~ /C_Unique/ || $fileName =~ /Org3-Org1- Org2.C_unique/) { print "2 Searching file: $file_names[1]"; @file_names = ($file_names[1]); # SE_Org3 } elsif($fileName =~ /ABC/ || $fileName =~ /AB/ || $fileName =~ / AC98/ || $fileName =~ /AC90/ || $fileName =~ /A_Unique/ || $fileName =~ /Org1-Org2- Org3.A_unique/ || $fileName =~ /Org1_Org2.common/ || $fileName =~ /Org1_Org2_Org3.common/ || $fileName =~ / Org1_Org3.common/) { print "3 Searching file: $file_names[2]"; @file_names = ($file_names[2]); # RP62A } print "$fileName => $file_names[0]\n"; you were probably expecting the file "Org1_Org2_Org3.common" to fall into the "3 Searching file" block, but it doesn't because you're catching that filename with your $fileName =~ /Org2_Org3.common/ regex up in the "1 Searching file" block. That's because "Org1_Org2_Org3.common" does indeed contain the string "Org2_Org3.common", which is the question your regex asks Perl to answer. You don't need regexs to do what you're doing, so you're less likely to get stung by just avoiding them like so: if($fileName eq "Org2_Org3.common" || $fileName eq "Org2-Org1- Org3.B_unique") { print "1 Searching file: $file_names[0]"; @file_names = ($file_names[0]); # ATC } elsif($fileName eq "Org3-Org1-Org2.C_unique") { print "2 Searching file: $file_names[1]"; @file_names = ($file_names[1]); # SE_Org3 } elsif($fileName eq "Org1-Org2-Org3.A_unique" || $fileName eq "Org1_Org2.common" || $fileName eq "Org1_Org2_Org3.common" || $fileName eq "Org1_Org3.common") { print "3 Searching file: $file_names[2]"; @file_names = ($file_names[2]); # RP62A } print "$fileName => $file_names[0]\n"; ... or something even tighter... :) Looks like that produces the output you were expecting? HTH, j From dan at linder.org Thu Jan 11 09:13:25 2007 From: dan at linder.org (Daniel Linder) Date: Thu, 11 Jan 2007 11:13:25 -0600 (CST) Subject: [Omaha.pm] requesting quick help In-Reply-To: <189A688A-C30A-4537-84C4-2AEA07046621@jays.net> References: <4DDFD9DB-AA66-4646-8C10-89821458A5B4@jays.net> <189A688A-C30A-4537-84C4-2AEA07046621@jays.net> Message-ID: <51705.63.230.40.29.1168535605.squirrel@www.linder.org> On Thu, January 11, 2007 07:51, Jay Hannah wrote: > (2) Given your filename list > > Org1_Org2.common > Org1-Org2-Org3.A_unique > Org1_Org2_Org3.common > Org1_Org3.common > Org2-Org1-Org3.B_unique > Org2_Org3.common > Org3-Org1-Org2.C_unique Boy, those file names sure look like something that a deranged CompSci teacher would come up with... ;) >From the "RegExp Hell" that was needed to solve this, I kinda wonder if there isn't a cleaner aproach. In other examples, if file are being produced by a real system, there is usually some sort of logic to their names. Based on that, a concise regular expression if..then..else will normally suffice. Getting back to the original (apparent) bug, just keep in mind that you want to have the most specific matches first, then fall back to broader and broader matches. (i.e. if you match for /*/ first thing, then everything else will be ignored...) Dan - - - - "Wait for that wisest of all counselors, time." -- Pericles "I do not fear computers, I fear the lack of them." -- Isaac Asimov From jay at jays.net Sat Jan 13 09:57:28 2007 From: jay at jays.net (Jay Hannah) Date: Sat, 13 Jan 2007 11:57:28 -0600 Subject: [Omaha.pm] Testing DNS servers Message-ID: <665fe04386b8f07d501b3b5305df14a6@jays.net> We're taking over DNS services for 113 domains on 3 new DNS servers w/ firewall mappings to the Internet.... How can I KNOW that everything is working? I'm using Perl (surprise! -laugh-). Now I can just run "prove -r" from inside and outside our networks and 180 tests pass or fail. Across 3 DNS servers it'll be some 600ish tests. :) j e.g.: dns_from_inside.t use Test::More; eval { require Sys::HostIP }; plan skip_all => "Sys::HostIP required" if $@; my $ip_address = Sys::HostIP->ip; if ($ip_address =~ /^10\./) { plan tests => 88; } else { plan skip_all => "You can only run these tests from inside the Omni network. Your IP: [$ip_address]"; } my @servers = ( '@10.0.64.14 -p53', # royal '@10.0.33.164 -p53', # omares-netservices # etc... ); my @expect = qw( omnihotels.com A 63.241.199.252 www.omnihotels.com A 63.241.199.252 omnihotels.com MX mail.omnihotels.com # etc... ); run_tests(\@servers, \@expect); sub run_tests { my ($servers, $expect) = @_; for ($j = 0; $j < @$expect; $j += 3) { foreach my $server (@$servers) { my ($q, $type, $a) = @$expect[$j .. $j + 2]; my $cmd = "dig $server $q $type +noall +answer"; #print "[$cmd]\n"; my $resp = `$cmd`; #print "[$resp]\n"; ok($resp =~ /\Q$a\E/, "'$cmd' returns $a"); } } } From jay at jays.net Sat Jan 13 10:03:30 2007 From: jay at jays.net (Jay Hannah) Date: Sat, 13 Jan 2007 12:03:30 -0600 Subject: [Omaha.pm] use Storable; Message-ID: <3803904a85442045993a0eef19628ac1@jays.net> Wow. That's easy. store $stats, "stats.Storable"; ...later, in a different program... my $stats = retrieve("stats.Storable"); poof! My object and all attributes are magically back in Perl. $stats has children objects inside it, which have children objects inside them... Trey: What was that other module you used? DBM/Freeze or something? Does Storable do the same thing without adding a CPAN dependancy? (Storable is distributed w/ Perl itself.) j From jay at jays.net Sat Jan 13 10:17:07 2007 From: jay at jays.net (Jay Hannah) Date: Sat, 13 Jan 2007 12:17:07 -0600 Subject: [Omaha.pm] use Storable; In-Reply-To: <3803904a85442045993a0eef19628ac1@jays.net> References: <3803904a85442045993a0eef19628ac1@jays.net> Message-ID: On Jan 13, 2007, at 12:03 PM, Jay Hannah wrote: > ...later, in a different program... > > my $stats = retrieve("stats.Storable"); Oh, wacky... Calling methods on the $stats object doesn't actually work until I throw use statements in my program for $stats and all the objects inside $stats. So my $stats object is back in Perl but retarded until I add the necessary use statements. :) j $ cat j.pl use Storable; my $stats = retrieve('stats.Storable'); $stats->report("out"); $ perl j.pl Can't locate object method "report" via package "OpenLab::BlastStats" at j.pl line 7. $ $ cat j.pl use Storable; use OpenLab::BlastStats; use OpenLab::Pools; use OpenLab::H_Pools; my $stats = retrieve('stats.Storable'); $stats->report("out"); $ perl j.pl $ From jay at jays.net Sat Jan 13 11:10:13 2007 From: jay at jays.net (Jay Hannah) Date: Sat, 13 Jan 2007 13:10:13 -0600 Subject: [Omaha.pm] use Storable; vs. Log::Log4perl In-Reply-To: References: <3803904a85442045993a0eef19628ac1@jays.net> Message-ID: <5f2799d8e2d190e3c7bd2175342b2e27@jays.net> Bummer. I can't use Storable on Log::Log4perl objects... Or any object which has a Log::Log4perl in it... which is approximately all of my objects since I'm a big fan of Log::Log4perl... j $ cat j.pl use Storable; use Log::Log4perl; Log::Log4perl::init('/Users/jhannah/src/openlab/conf/log4perl.cfg'); my $logger = Log::Log4perl->get_logger('OpenLab'); store $logger, 'logger'; $ perl j.pl Can't store CODE items at blib/lib/Storable.pm (autosplit into blib/lib/auto/Storable/_store.al) line 215, at j.pl line 10 From jay at jays.net Tue Jan 16 09:07:44 2007 From: jay at jays.net (Jay Hannah) Date: Tue, 16 Jan 2007 11:07:44 -0600 (CST) Subject: [Omaha.pm] Testing DNS servers Message-ID: revision 1.2 date: 2007/01/16 16:28:42; author: jhannah; state: Exp; lines: +65 -17 I discovered a problem with my testing robot. The answers coming from the servers were not necessarily authoritative. This was a fatal design flaw because when the target server recurses to find the correct answer the test robot must detect that behavior and report it as a failure. I switched from parsing dig output to Net::DNS where I can explicitly check the aa (authoritative answer) bit to make sure that the answer I'm receiving isn't from cache. Also, in this version if you're expecting multiple responses (e.g.: 3 MX servers) you can pass an array reference in and the test will check all values. (There may be a sorting bug here that I haven't fixed.) use strict; use Test::More; eval { require Sys::HostIP }; plan skip_all => "Sys::HostIP required" if $@; eval { require Net::DNS::Resolver }; plan skip_all => "Net::DNS::Resolver required" if $@; my $ip_address = Sys::HostIP->ip; if ($ip_address =~ /^10\./) { plan skip_all => "You can only run these tests from the Internet. Your IP: [$ip_address]"; } else { plan tests => 102; } my @servers = ( '63.174.225.42', # omares-netservices's Internet IP '63.251.92.193', # dns3.corporatedomains.com ); my @expect = qw( omnihotels.com A 63.241.199.252 www.omnihotels.com A 63.241.199.252 # You can also pass array references like this: #'676restaurant.com', 'NS', [ 'ns.panomedia.net', 'ns1.panomedia.net' ], ); run_tests(\@servers, \@expect); exit; # ------------- sub run_tests { my ($servers, $expect) = @_; # Set up our resolver objects... my %resolvers; foreach my $server (@$servers) { my $res = Net::DNS::Resolver->new( nameservers => [ $server ], recurse => 0, #debug => 1 ); $resolvers{$server} = $res; } for (my $j = 0; $j < @$expect; $j += 3) { foreach my $server (@$servers) { my ($q, $type, $a) = @$expect[$j .. $j + 2]; my $res = $resolvers{$server}; my $packet = $res->search($q, $type); # Net::DNS::Packet object my @response; if ($packet) { ### Hmm... This NS theory is unproven, so I'm commenting it out. ###if ($type eq "NS") { ### # These don't have to be authoritative. When we delgate NS for a server ### # apparently named does not set the aa (authoritative answer) flag. ###} else { if ($packet->header->aa) { # Good. It's authoritative. } else { # Ack! Non-authoritative answer?? push @response, "ERROR! Server returned non-authoritative answer!"; } ###} foreach my $rr ($packet->answer) { next unless $rr->type eq $type; #print $rr->address, "\n"; if ($type eq "A") { push @response, $rr->address; } elsif ($type eq "NS") { push @response, $rr->nsdname; } elsif ($type eq "MX") { push @response, $rr->exchange; } elsif ($type eq "TXT") { push @response, $rr->txtdata; } } } if (ref $a eq "ARRAY") { # The test requested we check multiple values... is_deeply([@response], $a, "\@$server $q $type -> $a"); } else { is_deeply([@response], [$a], "\@$server $q $type -> $a"); } } } } From jhannah at omnihotels.com Wed Jan 17 08:30:51 2007 From: jhannah at omnihotels.com (Jay Hannah) Date: Wed, 17 Jan 2007 10:30:51 -0600 Subject: [Omaha.pm] Huh? Message-ID: > Just ran across this and it stuck me as weird. Any idea why this happens? > > Given a regex "^$|^\d{1,7}$" , the rule says > "A 0 length string OR a number 1 to 7 characters in length". It does? Are you sure about that first dollar sign? Wacky. In Perl the regex you describe would be /^(|\d{1,7})$/ (untested) or /^\d{1,7}?$/ (untested) ^ and $ would only occur at the very start and the very end. > Given a regex "^\d{1,7}|^$" , the rule says > "A number 1 to 7 characters in length OR a 0 length string ". > > For reasons I can't seem to fathom, the first regex evals the > way I want, the second fails the empty string test. Ever seen > this before? Perhaps it's just a weird .NET regex quirk? Uhh... I think my examples would pass in Perl. I can't comment on .NET off the top of my head. :) j From andy at petdance.com Wed Jan 17 08:48:19 2007 From: andy at petdance.com (Andy Lester) Date: Wed, 17 Jan 2007 10:48:19 -0600 Subject: [Omaha.pm] Huh? In-Reply-To: References: Message-ID: <1787CA00-4778-49C4-9C0D-554787F593C7@petdance.com> >> Given a regex "^$|^\d{1,7}$" , the rule says >> "A 0 length string OR a number 1 to 7 characters in length". that works in Perl. -- Andy Lester => andy at petdance.com => www.petdance.com => AIM:petdance From jhannah at omnihotels.com Wed Jan 17 10:25:15 2007 From: jhannah at omnihotels.com (Jay Hannah) Date: Wed, 17 Jan 2007 12:25:15 -0600 Subject: [Omaha.pm] FW: Huh? Message-ID: -----Original Message----- From: Thompson, Kenn [mailto:KThompson at heiskell.com] Sent: Wednesday, January 17, 2007 10:49 AM To: Jay Hannah Subject: RE: Huh? -->> -->> > Just ran across this and it stuck me as weird. Any idea why this -->> happens? -->> > -->> > Given a regex "^$|^\d{1,7}$" , the rule says -->> > "A 0 length string OR a number 1 to 7 characters in length". -->> -->> It does? Are you sure about that first dollar sign? Wacky. Well, it kind of did. The test script passed it, but the app did not. -->> -->> In Perl the regex you describe would be -->> -->> /^(|\d{1,7})$/ (untested) -->> -->> or -->> -->> /^\d{1,7}?$/ (untested) -->> -->> ^ and $ would only occur at the very start and the very end. -->> -->> > Given a regex "^\d{1,7}|^$" , the rule says -->> > "A number 1 to 7 characters in length OR a 0 length string ". -->> > -->> > For reasons I can't seem to fathom, the first regex evals the -->> > way I want, the second fails the empty string test. Ever seen -->> > this before? Perhaps it's just a weird .NET regex quirk? -->> -->> Uhh... I think my examples would pass in Perl. I can't -->> comment on .NET off the top of my head. :) -->> It's weird that it didn't complain about the multiple $. Your examples work as written tho (and make more sense to me). I forgot about the parens usage. I guess I need to go back to regex school. ;) From andy at petdance.com Wed Jan 17 10:27:34 2007 From: andy at petdance.com (Andy Lester) Date: Wed, 17 Jan 2007 12:27:34 -0600 Subject: [Omaha.pm] FW: Huh? In-Reply-To: References: Message-ID: On Jan 17, 2007, at 12:25 PM, Jay Hannah wrote: > It's weird that it didn't complain about the multiple $. A $ is just a condition, just like a \b. xoa -- Andy Lester => andy at petdance.com => www.petdance.com => AIM:petdance From jay at jays.net Thu Jan 18 18:20:46 2007 From: jay at jays.net (Jay Hannah) Date: Thu, 18 Jan 2007 20:20:46 -0600 Subject: [Omaha.pm] debugger question In-Reply-To: <531681ec0701180736g48176b16sb3966d40d3a7f7e2@mail.gmail.com> References: <531681ec0701180736g48176b16sb3966d40d3a7f7e2@mail.gmail.com> Message-ID: On Jan 18, 2007, at 9:36 AM, kiran bina wrote: > Hi Jay, > The output from the debugger is as below. How can I see the value of > $result and $Query_name ? > Thanks > kiran > > main::(second_step.pl:43):????? while ( my $result = > $searchio->next_result() ) > main::(second_step.pl:44):????? { > ? DB<3> n > main::(second_step.pl:47):????????? my $Query_name= > $result->query_name(); > ? DB<3> p $result; > Bio::Search::Result::BlastResult=HASH(0x8d5e140) > ? DB<4> p $Query_name; > Use of uninitialized value in print at (eval > 16)[/usr/share/perl/5.8/perl5db.pl:628] line 2, line 20. $result is an object, so you can't "print" it per-say, you have to call methods on the object. In the debugger you can usually see the guts iniside an object using "x", so x $result might show you interesting things. On the $Query_name front you haven't yet executed the line of code that will (probably) populate $Query_name, so the debugger gets unhappy. $Query_name doesn't exist until 1 line of code later. So if you move past that line of code n and then print $Query_name p $Query_name you might have something in there. Welcome to the fray, brave Perl debugger!! :) HTH, j From jay at jays.net Fri Jan 19 05:13:08 2007 From: jay at jays.net (Jay Hannah) Date: Fri, 19 Jan 2007 07:13:08 -0600 Subject: [Omaha.pm] Could use your help In-Reply-To: <531681ec0701180938u35e451bfq724d68fe7406e565@mail.gmail.com> References: <531681ec0701180938u35e451bfq724d68fe7406e565@mail.gmail.com> Message-ID: On Jan 18, 2007, at 11:38 AM, kiran bina wrote: > FILE: Has a lot of entries in random order of entries of my > interest. I am interested in selected few whose name I wish to get > from IN using the subroutine > Problem: This prints only 'C' even when I have entries in IN > which should allow printing A or B. > I think I do not have my return statement at the right place. > > while > { > $string= 'Foo'; > $status= find_member_status($string) > if ($string eq $status) > { > if (defined $object) > { > Print "A"; > } > else > { > Print "B"; > } > } > else > { > Print "C"; > } > } > > > sub find_member_status > { > my $name= shift; > my $rval= 'NA'; > my $no_match_name; > while (my $line=) > { > if ($line=~ /\>/) > { > $line=~ m/\>(gi\|\d+\|gb\|\S+\|)/; > $no_match_name= $1; > print "Name= $name\n"; > print "After: $no_match_name\n"; > if ($name eq $no_match_name) > { > $rval= $no_match_name; > # return $rval; > last; > } > > } > } > return $rval; > } Hmm... I think down here $line=~ m/\>(gi\|\d+\|gb\|\S+\|)/; $no_match_name= $1; print "Name= $name\n"; print "After: $no_match_name\n"; your regex is demanding 'gi|' followed by digits, etc. So $no_match_name will always be undef or start with 'gi|' followed by digits, etc. You should see that when you print "After: $no_match_name" ... ? So, when we back up to the top: $string= 'Foo'; $status= find_member_status($string) if ($string eq $status) $status will always be undef or start with 'gi|' followed by digits. So it will never eq 'Foo'. Perhaps you meant to test if $status *contains* 'Foo'? if ($status =~ /\Q$string\E/) ? HTH, j From jay at jays.net Fri Jan 19 05:56:33 2007 From: jay at jays.net (Jay Hannah) Date: Fri, 19 Jan 2007 07:56:33 -0600 Subject: [Omaha.pm] Could you take a look In-Reply-To: <531681ec0701190518r7f484709p8559ad6df24e6865@mail.gmail.com> References: <531681ec0701190518r7f484709p8559ad6df24e6865@mail.gmail.com> Message-ID: On Jan 19, 2007, at 7:18 AM, kiran bina wrote: > Could you please take a look at this. > Hi again Kiran. :) Your code (as viewed in the debugger): DB<6> l 9-15 9: while (my $line=) 10 { 11: if ($line=~ m/\>\s+/) 12 { 13: $line=~ m/^(\S+)\>\s(\S+)$/; 14==> my $read = $1; 15: my $value= $2; Your first problem is that $line has carriage returns and/or newlines at the end, so your regex demand that the line end with \S+ fails. I'll step past the regex and show you the newlines: main::(test.pl: 13): $line=~ m/^(\S+)\>\s(\S+)$/; DB<1> n main::(test.pl:14): my $read = $1; DB<3> p "[$line]" [a> APPLE ] Now normally you could just 'chomp $line;', but that didn't work for me on your data. Perhaps because my Mac defines newlines differently than wherever you made your file? Even after I added chomp it still wasn't working, so I x'd it in the debugger to see why not: DB<3> x $line 0 "a> APPLE\cM" Bummer. I believe "\r\n" (carriage return, linefeed) is interpreted as Control-M, So I added a regex to remove all carriage returns and linefeeds $line =~ s/[\r\n]//g; (chomp might work fine for you.) The next annoyance was all these warnings: Use of uninitialized value in string eq at test.pl line 43, line 5. Which you can avoid by NOT running look_up_order() if there is no $value. I don't know if that's what you wanted to do or not, but you can do that with this line next unless ($value); # No value in file... So your code now reads like this: while (my $line=) { $line =~ s/[\r\n]//g; if ($line=~ m/\>\s+/) { $line=~ m/^(\S+)\>\s(\S+)$/; my $read = $1; my $value= $2; next unless ($value); # No value in file... which seems to work? $ perl test.pl a APPLE b BOY d DOG ? Lower, your look_up_order() doesn't seem to do anything at all. Were you wanting it to pull values out of File2 if File1 didn't have a $value or something? HTH, j From kiranbina at gmail.com Fri Jan 19 06:16:54 2007 From: kiranbina at gmail.com (kiran bina) Date: Fri, 19 Jan 2007 08:16:54 -0600 Subject: [Omaha.pm] Could you take a look In-Reply-To: References: <531681ec0701190518r7f484709p8559ad6df24e6865@mail.gmail.com> Message-ID: <531681ec0701190616h660856afj14a4de5aade8007f@mail.gmail.com> I don't know if i did not formulate the problem right. This is what I wanted. The GI- number in File2 is a smaller subset of possible GI-in File 1 (This has the matching GI plus the sequence I am interested in). (Or. I want to pull all the sequences from file-1 using the GI listed in File 2) kiran On 1/19/07, Jay Hannah wrote: > > On Jan 19, 2007, at 7:18 AM, kiran bina wrote: > > Could you please take a look at this. > > > > Hi again Kiran. :) > > > Your code (as viewed in the debugger): > > > DB<6> l 9-15 > 9: while (my $line=) > 10 { > 11: if ($line=~ m/\>\s+/) > 12 { > 13: $line=~ m/^(\S+)\>\s(\S+)$/; > 14==> my $read = $1; > 15: my $value= $2; > > > Your first problem is that $line has carriage returns and/or newlines > at the end, so your regex demand that the line end with \S+ fails. > > I'll step past the regex and show you the newlines: > > > main::(test.pl: > 13): $line=~ m/^(\S+)\>\s(\S+)$/; > > DB<1> n > main::(test.pl:14): my $read = $1; > > > > > > DB<3> p "[$line]" > [a> APPLE > ] > > > Now normally you could just 'chomp $line;', but that didn't work for > me on your data. Perhaps because my Mac defines newlines differently > than wherever you made your file? Even after I added chomp it still > wasn't working, so I x'd it in the debugger to see why not: > > > DB<3> x $line > 0 "a> APPLE\cM" > > > Bummer. I believe "\r\n" (carriage return, linefeed) is interpreted > as Control-M, So I added a regex to remove all carriage returns and > linefeeds > > > $line =~ s/[\r\n]//g; > > > (chomp might work fine for you.) > > The next annoyance was all these warnings: > > > Use of uninitialized value in string eq at test.pl line 43, > line 5. > > > Which you can avoid by NOT running look_up_order() if there is no > $value. I don't know if that's what you wanted to do or not, but you > can do that with this line > > > next unless ($value); # No value in file... > > > So your code now reads like this: > > > while (my $line=) > { > $line =~ s/[\r\n]//g; > if ($line=~ m/\>\s+/) > { > $line=~ m/^(\S+)\>\s(\S+)$/; > my $read = $1; > my $value= $2; > next unless ($value); # No value in file... > > > which seems to work? > > > $ perl test.pl > a > APPLE > b > BOY > d > DOG > > > ? > > Lower, your look_up_order() doesn't seem to do anything at all. Were > you wanting it to pull values out of File2 if File1 didn't have a > $value or something? > > HTH, > > j > > > _______________________________________________ > Omaha-pm mailing list > Omaha-pm at pm.org > http://mail.pm.org/mailman/listinfo/omaha-pm > -- Dhundy R. Bastola Assistant Professor Department of Pediatrics University of Nebraska Medical Center Omaha NE 68198 Always reply to: dbastola at unmc.edu -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.pm.org/pipermail/omaha-pm/attachments/20070119/2590102e/attachment.html From jay at jays.net Sat Jan 20 05:28:39 2007 From: jay at jays.net (Jay Hannah) Date: Sat, 20 Jan 2007 07:28:39 -0600 Subject: [Omaha.pm] [dynamic_omaha] Is this getting traction? In-Reply-To: <45B0DAF6.6090903@gmail.com> References: <45B0DAF6.6090903@gmail.com> Message-ID: On Jan 19, 2007, at 8:51 AM, Matt Payne wrote: > "ScriptDoc is an attempt to standardize documentation formats > for dynamic languages. Read the proposal specification and get > involved!" -- http://www.scriptdoc.org/ > > Is this getting traction? There's about a billion documents in Perl using "POD". http://perldoc.perl.org/perlpod.html But POD doesn't dictate rules for GUI tools to "autocomplete" method names, so you'd have to layer in additional (scriptdoc-like) syntax for that inside your Perl. e.g. Komodo: http://www.activestate.com/_images/untour/screenshots/ write_great_code.png http://www.activestate.com/Products/Komodo/more_information.plex Every Perl person I know uses vi or emacs anyway. :) j From jay at jays.net Sat Jan 20 08:27:01 2007 From: jay at jays.net (Jay Hannah) Date: Sat, 20 Jan 2007 10:27:01 -0600 Subject: [Omaha.pm] offutt.pm.org In-Reply-To: <200612111327.kBBDRPDI005209@off-cits-01.offutt.af.mil> References: <200612111327.kBBDRPDI005209@off-cits-01.offutt.af.mil> Message-ID: (Can't remember if I replied to this once already.) Hi again Steven -- I'm all for a joint meeting! I've been ferreting myself into the Dynamic Language Users group too, so a Borgian assimilation is inevitable. Whenever you're ready just drop us a line! Are you a member of our mailing list? If not, you're certainly welcome to join and discuss meeting topics. http://mail.pm.org/mailman/listinfo/omaha-pm I just kind of wing the meetings at Omaha.pm... I was going to join your mailing list, but wasn't sure if you wanted it to be Offutt-only or anything. -ponder- The panty raid could get a little messy, what with all those guns and planes and stuff you guys have. What's up with that anyway? Are you trying to start a Nebraskan Perl Mongers arms race or something? :) j On Dec 11, 2006, at 7:27 AM, Bush Steven A1C AFWA/SCSA wrote: > Unfortunately I have not managed to get everything going with the group > yet. I have about 3 people that I have found that are interested; > however, I have been really busy lately as I am getting married at the > end of the month, and just moved off base. I am hoping to gather a > reasonable size group up and have regular scheduled meetings by the end > of February. Maybe we could co-ordinate a Joint meeting at some point > in > '07? As far as panty raids go, I think I'll have to hide in the > relative > safety of the base until I have a large enough group to fight you off > ;-P > > Also, do you have any suggestions for meeting topics? In my old PMG we > had topics like Templating engine comparisons (I'm a Petal man > personally) or a discussion of new modules in CPAN. > > //SIGNED// > STEVEN BUSH, A1C, USAF > Software Applications Technician > HQ Air Force Weather Agency / SCSA > Comm: (402) 232-0163 > DSN: 272-0163 > > -----Original Message----- > From: Jay Hannah [mailto:jay at jays.net] > Sent: Saturday, December 09, 2006 10:09 AM > To: Bush Steven A1C AFWA/SCSA > Cc: Nebraska USA Perl Mongers of Omaha > Subject: offutt.pm.org > > Hi Steven -- > > How's your new Offutt AFB Perl Monger group coming along? > > http://offutt.pm.org/ > > Your cohorts over here in Omaha.pm want to know! Our panty raid > plans are all on hold over here. :) > > j From jay at jays.net Sun Jan 21 05:33:10 2007 From: jay at jays.net (Jay Hannah) Date: Sun, 21 Jan 2007 07:33:10 -0600 Subject: [Omaha.pm] Could you take a look In-Reply-To: <531681ec0701190616h660856afj14a4de5aade8007f@mail.gmail.com> References: <531681ec0701190518r7f484709p8559ad6df24e6865@mail.gmail.com> <531681ec0701190616h660856afj14a4de5aade8007f@mail.gmail.com> Message-ID: <34C7E787-682A-4FA3-95D2-A76CD15E797F@jays.net> On Jan 19, 2007, at 8:16 AM, kiran bina wrote: > I don't know if i did not formulate the problem right. This is what > I wanted. > The GI- number in File2 is a smaller subset of possible GI-in File > 1 (This has the matching GI plus the sequence I am interested in). > (Or. I want to pull all the sequences from file-1 using the GI > listed in File 2) > kiran As discussed yesterday I'm glad you got those figured out. It gets pretty hard to describe these things via email. For me finding the 1-3 lines of code that aren't doing what I thought they would is usually the hardest part. Stepping through with the debugger is great for checking expectations one line of code at a time. Once you're hooked on the debugger its hard to live without it. -grin- j From jay at jays.net Wed Jan 31 04:13:22 2007 From: jay at jays.net (Jay Hannah) Date: Wed, 31 Jan 2007 06:13:22 -0600 Subject: [Omaha.pm] Job Snag-O (WWW::Mechanize) Message-ID: My brother lives down in Kansas City. He's trying this whole substitute teacher thing. Every morning at 5:30am he has to wake up and check a website to see if there are any jobs available. That sucks... Why not just have a robot page you awake if there ARE jobs available? Isn't WWW::Mechanize da bomb? It took me 30 minutes to get this working: $ cat jobs.pl #!/usr/bin/perl use WWW::Mechanize; my $base_url = "https://secure.indep.k12.mo.us/webconnect"; my $url1 = "$base_url/login/login.asp"; my $lastname = "********"; my $password = "********"; my $url2 = "$base_url/sub/SubAvailableJobs.ASP"; my $mech = WWW::Mechanize->new(); $mech->get( $url1 ); $mech->submit_form( form_name => 'frmLogin', fields => { LastName => $lastname, PinNumber => $password }, ); $mech->get( $url2 ); my $text = $mech->content; $text =~ s/.*/ /sg; print $text; So now, you can just run the program instead having to log into the website: $ perl jobs.pl 6:06 AM Available Jobs 1/31/2007 No jobs available at this time. So I threw that in cron to run every 15 minutes and email us... */15 4-7 * * * /usr/bin/perl /home/jhannah/brad/jobs.pl | mail -s "Job Snag-O" crapulence at yahoo.com,jay at jays.net Now if only my brother had a pager I could wake him up if there was a job... :) j P.S. Perl is the coolest. From PMHanson at west.com Wed Jan 31 09:07:25 2007 From: PMHanson at west.com (Hanson, Paul M.) Date: Wed, 31 Jan 2007 11:07:25 -0600 Subject: [Omaha.pm] Job Snag-O (WWW::Mechanize) References: Message-ID: <918A98520F3FCE409850AB28CDC2E3D501100013@OMAEXMB01.corp.westworlds.com> If he has a cell phone that accepts text messages, couldn't you send a short "Nothing" to that device?