phillup's Journal http://use.perl.org/~phillup/journal/ phillup's use Perl Journal en-us use Perl; is Copyright 1998-2006, Chris Nandor. Stories, comments, journals, and other submissions posted on use Perl; are Copyright their respective owners. 2012-01-25T02:23:38+00:00 pudge pudge@perl.org Technology hourly 1 1970-01-01T00:00+00:00 phillup's Journal http://use.perl.org/images/topics/useperl.gif http://use.perl.org/~phillup/journal/ Slow day http://use.perl.org/~phillup/journal/26746?from=rss <p>When I woke up this morning I realized that my high speed internet wasn't working.</p><p>So... I'm relegated to using my backup which is thru a different ISP via a modem. (I work from home)</p><p>Ugh.</p><p>I had forgotten how slow life was in the modem lane.</p> phillup 2005-09-16T23:00:54+00:00 journal &amp;start=720 http://use.perl.org/~phillup/journal/26607?from=rss <p>We bought <a href="http://use.perl.org/~phillup/journal/24388">a camper</a> earlier this year since our oldest will be at that age next year where you get tied to the school schedule.</p><p>It has been a blast.</p><p>The downside is that I've had to let a few things slide over the summer in order to take off every other weekend for three days and still get stuff done for my clients.</p><p>One of those things has been reading the blogs on this site.</p><p>I normally use <a href="http://use.perl.org/search.pl?op=journals">this URL</a> and hit the Next 30 Matches link to get to the last entry I read and catch up.</p><p>Last week that put me about 720 journal entries behind. I thought about just skipping them... but it was kinda nice to see all the conversation.</p><p>Normally I read the entries before others comment and miss a lot of the feedback.</p><p>Anyways... I just finished catching up.</p><p>Just in time for a five day trip to the west coast starting Thursday.</p><p><nobr> <wbr></nobr>:-)</p> phillup 2005-09-05T23:22:24+00:00 journal $inserted == 0E0? http://use.perl.org/~phillup/journal/24610?from=rss <p>Posted here to help any others that have this problem.</p><p>I updated my Debian workstation yesterday.</p><p>Suddenly, my web based application that I work on was telling me that inserting data into the mysql database was inserting zero rows. But, the data was actually being inserted!</p><blockquote><div><p> <tt>my $rows = $sth-&gt;execute($data, $to, $add);</tt></p></div> </blockquote><p>Always returned a value of '0E0' with no errors or warnings, when it should be returning a value of '1'. But, only when running under mod_perl.</p><p>However, all of my tests passed with flying colors... and eveything worked perfectly in a command line environment.</p><p>Something was obviously different between the two environments but no amount of poking on my part could figure out what that something was.</p><p>(Lesson learned: tee the output of apt-get upgrade to a file to record what software was changed!)</p><p>Anyways... I noticed I had two libmysqlclient* libraries installed...</p><p>After removing libmysqlclient10, leaving libmysqlclient12, everything works again.</p><p>Apparently, libmysqlclient10 is used by mysql navigator... which I don't use any way.</p><p>---</p><p>Does anyone know how mod_perl decides which mysql client library to load... and how I could have narrowed down the problem? I'm thinking the problem may be DBI related, since I use Apache::DBI in the mod_perl environment but not in the bash environment... but that is just a guess.</p><p>Right now, finding a solution was just blind luck on my part! I was minutes away from restoring my backup, but kept poking at it since the problem is not likely to go away as Debian stabilizes towards the next version.</p><p>TIA</p> phillup 2005-05-10T17:10:16+00:00 journal Slash and paging http://use.perl.org/~phillup/journal/24572?from=rss <p>I've never understood the algorithm that Slashcode uses for paging comments.</p><p>For example, if I go and read <a href="http://science.slashdot.org/comments.pl?sid=148578&amp;threshold=0&amp;commentsort=0&amp;tid=146&amp;tid=14&amp;tid=219&amp;mode=nested&amp;startat=100&amp;pid=0">this article on Slashdot</a> and get to the bottom of the first page... how do I read the very next comment?</p><p>Clicking on the '2' just shows me page one all over again when the thread on page one spans two pages...</p> phillup 2005-05-06T21:34:08+00:00 journal Right needs more help http://use.perl.org/~phillup/journal/24414?from=rss <p>I'm constantly amazed at how much <a href="http://news.yahoo.com/news?tmpl=story&amp;u=/ap/20050427/ap_en_mo/bush_sanitizing_hollywood_2">help</a> the right needs when it comes to raising their kids.</p><p>It's like welfare for the "moral"... Of little use to most people.</p><p>I've never had a problem sending my kid to his room to play when I watch shows I don't think he should see. And I've never had a problem watching them when he is in bed.</p><p>Somehow I just don't think 'Blade: Trinity' would be the same...</p> phillup 2005-04-27T22:40:03+00:00 journal Judge for yourself http://use.perl.org/~phillup/journal/24413?from=rss <p>Why is it that there is <a href="http://www.csmonitor.com/2005/0413/p15s02-usju.html">so</a> <a href="http://www.washingtonpost.com/wp-dyn/articles/A26236-2005Apr4.html">much</a> <a href="http://www.washingtonpost.com/wp-dyn/articles/A42691-2005Apr10.html">talk</a> from the GOP about reining in judges, while at the same time trying <a href="http://mediamatters.org/items/200504260001">desperately</a> to make it easier to put judges on the bench?</p><p>It seems to me that the proper response would be greater scrutiny, with a corresponding lower approval rating.</p><p>What I find really interesting, is all the complaining by the Republicans when <a href="http://www.acsblog.org/judicial-nominations-886-guest-blogger-beyond-the-tipping-point.html">75% of the judges are Republican appointees</a>. Perhaps they really should look at the "<a href="http://www.time.com/time/archive/preview/0,10987,954982,00.html">follow the leader</a>" system they use.</p><p><b>Added:</b></p><p>Also, <a href="http://mediamatters.org/items/200504220006">Three more judicial filibuster falsehoods</a>.</p> phillup 2005-04-27T21:50:07+00:00 journal bootstraping http://use.perl.org/~phillup/journal/24388?from=rss <p>I bought a pop-up camper in January at an RV show.</p><p>Since I bought it in a different state than the one I live in, they gave me a three day temporary tag... on Friday. Good for Friday, Saturday and Sunday.</p><p>So, when Monday rolls around... I don't have a valid license plate to drive on the road with the trailer.</p><p>Since I'm not going to go camping in January anyway... I park the thing.</p><p>Now, it is time to get ready and I go to the DMV to get license plates.</p><p>The kicker: You can't get license plates until you drive the trailer to the DMV office and let them verify the VIN. And no, you can not get temporary plates.</p><p>So, in order to legally drive on the road you need license plates, which you can't get until you drive the vehicle to the DMV.</p><p>The police were also very helpful when asked for advice: Don't get caught.</p><p>Nice.</p> phillup 2005-04-26T23:47:55+00:00 journal It's good to be the king http://use.perl.org/~phillup/journal/24366?from=rss <p><i>So anyone who donated money to the minority party candidate in this past presidential election, regardless of their level of technical expertise, is now, according to a White House spokesman, unfit for participation in the international standards setting process. The Bush administration may deny that they pressure scientists politically, but engineers are apparently fair game not just for ideologically driven political pressure, but for partisan political pressure.</i></p><p><a href="http://arstechnica.com/news.ars/post/20050425-4842.html">Source</a></p><p><b>Update: </b>Now being covered <a href="http://hardware.slashdot.org/article.pl?sid=05/04/25/2116250&amp;tid=215">on Slashdot</a></p> phillup 2005-04-25T18:41:05+00:00 journal Say it isn't so! http://use.perl.org/~phillup/journal/24323?from=rss <p>While <a href="http://use.perl.org/comments.pl?sid=26164&amp;cid=39903">playing around earlier</a> with Google <a href="http://www.timboucher.com/journal/2005/04/21/jewish-leaders-dismiss-nazi-pope-worries/">I came across this</a>:</p><blockquote><div><p> <tt>Wait, by joining in the army (whether or not he claims to have "fired a shot"), wasn't Ratzinger actually defending the Third Reich?</tt></p></div> </blockquote><p>Which would not have really stood out to me, except I had just read <a href="http://www.timesonline.co.uk/article/0,,20709-1580888,00.html">this</a> earlier:</p><blockquote><div><p> <tt>"On the contrary, precisely because they are iniquitous the Church makes an urgent call for freedom of conscience and the duty to oppose.<br> &nbsp; <br>"A law as profoundly iniquitous as this one is not an obligation, it cannot be an obligation. One cannot say that a law is right simply because it is law."<br> &nbsp; <br>He called on municipal officials asked to perform gay marriages to object on grounds of conscience and to refuse to go through with the ceremony, even if it meant losing their jobs.<br> &nbsp; <br>He said: "They should exercise the same conscientious objection asked of doctors and nurses against a crime such as abortion.<br> &nbsp; <br>"This is not a matter of choice: all Christians... must be prepared to pay the highest price, including the loss of a job."</tt></p></div> </blockquote><p>"The highest price" seems to stop short of not joining an army whose cause you don't believe in.</p><p>Convenient.</p> phillup 2005-04-22T22:21:15+00:00 journal This is so wrong http://use.perl.org/~phillup/journal/24317?from=rss <blockquote><div><p> <tt>"Laws must be in accordance with the well-being of the human person, that is the key condition for a law to be respected,"<br> &nbsp; <br>...<br> &nbsp; <br>"If the law goes directly against true values then it is not a law, since an unjust law just ceases to exist," said Archbishop Karlic.</tt></p></div> </blockquote><p> <a href="http://www.cwnews.com/news/viewstory.cfm?recnum=15355">source</a></p><p><b>Update: </b>I just noticed that this article was from 2001. So, change tense as appropriate.</p> phillup 2005-04-22T15:24:50+00:00 journal It's so good, we use it ourselves http://use.perl.org/~phillup/journal/23981?from=rss <p>I saw an entry in FreshMeat that sounded interesting. When I went to <a href="http://www.formfields.com/gMenuArea/index.php">the home page for the software</a> I saw two statements that were a bit interesting to me:</p><blockquote><div><p> <tt>A GPL'd drop down menu that is so good that even we use it.</tt></p></div> </blockquote><p>and</p><blockquote><div><p> <tt>It's about time that someone released an open source drop down menu that actually works!</tt></p></div> </blockquote><p>Why did I find them interesting? Well... the drop down menus on the site don't work for me. That's why.</p><p>(Mozilla 1.7.6 on OSX 1.3.7)</p> phillup 2005-04-01T20:21:50+00:00 journal Government Intrusion http://use.perl.org/~phillup/journal/23944?from=rss <p>I came across <a href="http://wireservice.wired.com/wired/story.asp?section=Breaking&amp;storyId=1011355&amp;tw=wn_wire_story">this</a> in the paper today:</p><blockquote><div><p> <tt>The lawsuit seeks to abolish the nearly 200-year-old - and rarely enforced - law that prohibits unmarried, unrelated adults of the opposite sex from living together. North Carolina is one of seven states with such a law.</tt></p></div> </blockquote><p>The first thought in my mind (OK, the second) was... Hm... I bet it is OK for two people of the same gender to live together.</p><p>Hm... wonder what signal *that* sends.</p><p>I'm sure they are working feverishly to outlaw room mates.</p> phillup 2005-03-31T01:31:28+00:00 journal iPod Compatibility http://use.perl.org/~phillup/journal/23197?from=rss <p>I just got the latest Herrington catalog in the mail.</p><p>On the front cover is <a href="http://www.herringtoncatalog.com/as607.html">a radio</a> claiming <i>Virtuoso Sound and iPod Compatibility</i>.</p><p>What makes it iPod compatible?</p><blockquote><div><p> <tt>Or turn to &amp;#8220;AUX&amp;#8221;, plug in your iPod, and enjoy your entire library of iTunes with room-filling sound!</tt></p></div> </blockquote><p>Kinda makes me wonder how much the "Windows Compatible" version is...</p> phillup 2005-02-15T00:39:49+00:00 journal Quote of the week http://use.perl.org/~phillup/journal/23150?from=rss <p><i>Corporates need to think twice before using Firefox because it has repeatedly been targeted by worms and viruses.</i></p><p><a href="http://www.earthtimes.org/articles/show/1572.html">http://www.earthtimes.org/articles/show/1572.html</a></p> phillup 2005-02-11T19:19:41+00:00 journal Familiar Names http://use.perl.org/~phillup/journal/23117?from=rss <p>I read an article the other day (but I can't remember what or where it was) that didn't make much of an impression on me.</p><p>But something about it kept niggling in the back of my mind.</p><p>Well, today I read <a href="http://www.techworld.com/opsys/news/index.cfm?NewsID=3094">another one</a> that reminded me what the niggling was about.</p><p><a href="http://interglacial.com/~sburke/">Sean Burke</a> meet <a href="http://www.shawnburke.com/default.aspx?document=1">Shawn Burke</a>.</p><p>It isn't uncommon to find people with the same or similar names, but when I read the article and noted that it was relating to the computing industry... well... I did have to double-check that it wasn't the same person.</p> phillup 2005-02-10T06:08:34+00:00 journal Lies and Democracy http://use.perl.org/~phillup/journal/23115?from=rss <blockquote><div><p> <tt> Pfiffner's third, and most troublesome, category of presidential untruthfulness he labels as lies of policy deception, where "a president says that the government is doing one thing when in fact it is doing another."<br> &nbsp; <br>Pfiffner explains that "misleading the public about the direction of government policy does not allow the electorate to make an informed choice and undermines the premise of the democratic process." He cites the work of American philosopher and ethicist Sissela Bok to suggest why such deception is abhorrent: "It allows those in power to override or nullify the right vested in the people to cast an informed vote in critical elections."</tt></p></div> </blockquote><p> <a href="http://writ.news.findlaw.com/dean/20031024.html">http://writ.news.findlaw.com/dean/20031024.html</a></p> phillup 2005-02-10T00:50:38+00:00 journal Unexpected Linkage http://use.perl.org/~phillup/journal/23114?from=rss <p>While reading an article on <a href="http://story.news.yahoo.com/news?tmpl=story&amp;cid=584&amp;e=3&amp;u=/nm/20050208/pl_nm/congress_budget_dc">the Bush budget proposal</a>, I did not expect to find a hyperlink to news stories about <a href="http://news.search.yahoo.com/search/news?fr=news-storylinks&amp;p=%22Mount%0AEverest%22&amp;c=&amp;n=20&amp;yn=c&amp;c=news&amp;cs=nw">Mount Everest</a>!</p><p>(At least not in the body of the article... all bets are off when including headers, footers and sidebars.)</p> phillup 2005-02-09T23:41:04+00:00 journal Bush Lies http://use.perl.org/~phillup/journal/23112?from=rss <p>This morning I read an article in the (somewhat) local paper that had the words "Bush Lying" in the heading. That isn't news to me, but it was certainly out of character for the newspaper. The newspaper has an online site, but it seems pretty lame to me. So, <a href="http://www.spokesmanreview.com/news/cover.asp?pubdate=2/8/2005">this link</a> may or may not show you the synopsis of the article.</p><p>While looking for a linkable version, I stumbled across <a href="http://www.bushwatch.com/bushlies.htm">an interesting site</a> that had a quote I can identify with.</p><blockquote><div><p> <tt>Other Bush backers claim that some of his lies are "technically correct" or "tailored to fit the audience," or some such circumlocution. What they're talking about are lies of omission rather than lies of commission. In lies of omission it's what they imply, not what they say. For example, the other evening Bush told Congress and the American people that he was putting a "lock box" on Social Security. Now, it's very clear that Bush wanted us to feel secure in the belief that he was protecting all of our Social Security funds for the future. No question, right? Yet, the very next day when his budget book was released, we learned that Bush told a lie of omission. What he didn't tell Congress and the American people is that he would later take from $.6 to $1 trillion out of that "lock box" to cover his tax cuts. No doubt, Bush lied. He wanted folks to believe something that he knew was not true. Of course, politicians do this all the time. It's second nature. In sum, the thing that really bothers us about Bush's lies is that he is also a hypocrite and pretends he's above lying. As a liar, he reinforces our assumptions about politicians. As a hypocrite, he reinforces our assumptions about his character.</tt></p></div> </blockquote><p>I also think that the quote is somewhat pertinent since it is a "blast from the past" about statements Bush has made regarding Social Security.</p><p>Meanwhile we see this <a href="http://www.boston.com/news/globe/editorial_opinion/oped/articles/2005/02/08/budget_shenanigans/">little snippet</a>:</p><blockquote><div><p> <tt>The first clue to the truth lies in a measure of the federal deficit this crowd adores obscuring but is forced by law to disclose. It's found only in a large table buried in the budget documents and estimates the government's operating red ink -- the amount by which spending exceeds revenue from income taxes and other fees. Last year it was far above the deficit figure that that typically makes its way into headlines -- $567 billion, compared with the "official" figure of $412 billion.<br> &nbsp; <br>The difference is almost entirely accounted for by the large surplus in Social Security payroll taxes over benefit spending that the government "borrows" to make the books look less ridiculous.</tt></p></div> </blockquote><p>Which is the first time I've ever seen the link between deficit spending and Social Security even hinted at.</p><p>At the end of the day, all money comes from the general fund. There is no "lock box" holding a separate pile of cash for Social Security.</p><p>Yet, GWB says that Social Security will be bankrupt. He omits to tell us that this can't really happen without the government itself being bankrupt.</p><p>GWB tells us that he will reduce the deficit by half by some future date with his budget. He omits to tell us that the budget does not include the cost of his proposed SS reforms or the current wars. Or, that with those included he can't possibly meet that goal.</p><p>He also omits telling the people that this assumes congress does not pass another tax cut, <a href="http://www.boston.com/news/nation/washington/articles/2005/02/08/key_expenses_are_omitted_analysts_say?pg=2">to include making the current temporary tax cuts permanent</a>. One of his "mandate" items.</p><p>---</p><p>Unfortunately, I haven't been able to find a version of the article I read in the paper "in the wild".</p><p>The article talks about how the Bush numbers assume a growth rate of 1.8 percent, when the economy has never, ever performed so poorly during any 15 year period.</p><p>Even during the depression it grew at two percent.</p><p>One of the things that stood out to me in the article was this snippet:</p><blockquote><div><p> <tt>The administration is projecting a 6 percent growth in the stock market for the investment accounts. But the market is linked with the economy -- so if the economy truly grows at 1.8 percent as the projections say, there's no way for the market to grow at 6 percent.<br> &nbsp; <br>"It is mathematically impossible to see the return Bush is promising." he said.</tt></p></div> </blockquote><p>("He" is Doug Orr, the economist that charges Bush is lying.)</p><p>I'd really like to see the proof of that mathematical impossibility.</p><p><b>UPDATED:</b> speling</p> phillup 2005-02-09T22:49:24+00:00 journal Neutrality http://use.perl.org/~phillup/journal/21912?from=rss <p>There has been a little stink at the CIA lately about an internal email sent by the new head honcho. Of note is the following:</p><blockquote><div><p> <tt>As agency employees we do not identify with, support or champion opposition to the administration or its policies.</tt></p></div> </blockquote><p>Now, the spin has been that he is trying to convey the idea that the data speaks for itself. That the CIA itself is neutral.</p><p>Well, I give the honcho an "F" for clarity. The statement, to me, reeks of one sidedness... not neutrality. To see why, let's change a phrase to it's opposite and see if the resulting statement can be contorted to still have the same meaning.</p><blockquote><div><p> <tt>As agency employees we do not identify with, support or champion agreement with the administration or its policies.</tt></p></div> </blockquote><p>I think that statement would cause a firestorm among the Republicans.</p><p>In mathematics |x| + |-x| gets larger as the value of x moves from zero. I think that negating the above statement shows just how far from neutral the original message is.</p><p>If the true intent was to promote neutrality, then this was an abysmal failure. Communication skills are the foundation of good leadership. I hope that is not a sign of things to come.</p> phillup 2004-11-18T20:31:54+00:00 journal Testing Mason autohandlers http://use.perl.org/~phillup/journal/21832?from=rss <p>In <a href="http://use.perl.org/~phillup/journal/21827">my last installment</a> I found out that destruction of objects durning global garbage collection happens in a somewhat random order.</p><p>So, I need to make sure that all of my code undefines the $session instead of letting Perl do it for me. This way I know that the objects I'm referring haven't been destroyed yet and I can clean up properly.</p><p>Since this code runs in a Mason environment, the natural thing to do was insert a cleanup section in my autohandlers. But, I wasn't sure I had got them all.</p><p>And, I wanted to make sure that if I created an autohandler in the future that I remembered to clean my session.</p><p>Since I'm working on tests for the application, this seemed like a natural fit. So, I wrote a test to check all of my autohandlers for the correct code.</p><p>Now, if I create another autohandler it will get caught by the test script. At the very worst I'll have to update the plan. But, I won't forget to clean my session!</p><p>--- the code ---</p><blockquote><div><p> <tt>#!/usr/bin/perl<br> &nbsp; <br># check all of the autohandlers and dhandlers and make sure that they have a cleanup section<br># that undefines the $session variable if they do not inherit from another file<br> &nbsp; <br>use strict;<br>use warnings;<br> &nbsp; <br>use Test::More tests =&gt; 20;<br> &nbsp; <br># start in this directory<br>my $app_dir = '/home/Mason/comp/Gradebook/';<br> &nbsp; <br>use File::Find::Rule;<br> &nbsp; <br>my $rule = File::Find::Rule-&gt;new;<br>$rule-&gt;or(<br>&nbsp; &nbsp; $rule-&gt;new-&gt;directory-&gt;name('CVS')-&gt;prune-&gt;discard,<br>&nbsp; &nbsp; $rule-&gt;new-&gt;directory-&gt;name('Admin')-&gt;prune-&gt;discard,<br>&nbsp; &nbsp; $rule-&gt;new-&gt;file-&gt;name('autohandler'),<br>&nbsp; &nbsp; $rule-&gt;new-&gt;file-&gt;name('dhandler')<br>&nbsp; );<br> &nbsp; <br>my @files = $rule-&gt;in($app_dir);<br> &nbsp; <br>foreach my $handler (@files) {<br>&nbsp; # open our file and read it in<br>&nbsp; open I, $handler or print 'Bail out!';<br>&nbsp; local $/;<br>&nbsp; my $code = &lt;I&gt;;<br>&nbsp; close I;<br> &nbsp; <br>&nbsp; # first we need to check and see if this autohandler inherits from another<br>&nbsp; if ($code =~ m|^&lt;%flags&gt;\ninherit=&gt;'undef'\n&lt;/%flags&gt;|sm){<br> &nbsp; <br>&nbsp; &nbsp; # if it doesn't then it should have a cleanup section<br>&nbsp; &nbsp; # let's grab the contents<br>&nbsp; &nbsp; $code =~ m|^&lt;%cleanup&gt;(.*)&lt;/%cleanup&gt;|sm;<br>&nbsp; &nbsp; my $cleanup = $1 || ''; # so we don't trigger a warning with undefined scalar<br> &nbsp; <br>&nbsp; &nbsp; # and check to see that we are triggering the DESTROY method of our session<br>&nbsp; &nbsp; ok( $cleanup =~ m|undef \$session;$|sm , "$handler cleans the session" );<br> &nbsp; } # if inherits<br> &nbsp; <br>} # foreach handler</tt></p></div> </blockquote> phillup 2004-11-13T00:56:30+00:00 journal Garbage Collection Strangeness http://use.perl.org/~phillup/journal/21827?from=rss <p>Here is a minimal script that demonstrates (on my system) the strange behavior <a href="http://use.perl.org/~phillup/journal/21817">I am experiencing.</a></p><p>If I uncomment the undef statement, then everything seems to work. But, if I let Perl take out the garbage it looks like my CGI::Session object gets destroyed before my own session object is destroyed. Even tho I still have a reference to the object. (Actually, my reference goes away!)</p><p>I can work around the problem by making sure I trigger the object destruction myself. But, I'd really like to know if the problem is in my mental picture of how things are supposed to work.</p><p>UPDATE: It appears to be my mental picture.<nobr> <wbr></nobr>;-)</p><p>Apparently global garbage destruction is somewhat random in order. So, make sure you take out your own garbage if the order is important!</p><p>Any comments greatly appreciated!</p><p>-------</p><blockquote><div><p> <tt>#!<nobr> <wbr></nobr>/usr/bin/perl<br> &nbsp; <br>use strict;<br>use warnings;<br> &nbsp; <br>my $session = new My::Session;<br> &nbsp; <br>sub skipme{<br>&nbsp; my $test = $session-&gt;{test}; # no I don't normally access the object data directly<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# I just need to use the object in the sub to trigger<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# the problem and I want to reduce the number of methods<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# to the bare minimum to demonstrate the problem<br>} # sub skipme<br> &nbsp; <br>print "\nDone\n";<br>#undef $session;<br> &nbsp; <br>{#----------------------------------------------------------------- <br> &nbsp; <br>&nbsp; package My::Session;<br> &nbsp; <br>&nbsp; use strict;<br>&nbsp; use warnings;<br> &nbsp; <br>&nbsp; my $session_dir = '/tmp/cgisession/';<br>&nbsp; use CGI::Session::File;<br> &nbsp; <br>&nbsp; sub new{<br>&nbsp; &nbsp; # get our class of object<br>&nbsp; &nbsp; my $CLASS = shift;<br> &nbsp; <br>&nbsp; &nbsp; my $SELF = {};<br> &nbsp; <br>&nbsp; &nbsp; # get a new storage session<br>&nbsp; &nbsp; $SELF-&gt;{session} = new CGI::Session("driver:File;serializer:FreezeThaw", undef, {Directory =&gt; $session_dir})<br>&nbsp; &nbsp; &nbsp; || die 'Could not get new session store!';<br> &nbsp; <br>&nbsp; &nbsp; # and bless ourself<br>&nbsp; &nbsp; bless $SELF, $CLASS;<br> &nbsp; <br>&nbsp; &nbsp; return $SELF;<br>&nbsp; } # sub new<br> &nbsp; <br>&nbsp; sub DESTROY {<br>&nbsp; &nbsp; my $SELF = shift;<br> &nbsp; <br>&nbsp; &nbsp; print "Hey!! Someone stole my session!\n" unless $SELF-&gt;{session};<br>&nbsp; } # sub DESTROY<br> &nbsp; <br>}#-----------------------------------------------------------------</tt></p></div> </blockquote> phillup 2004-11-12T17:48:36+00:00 journal Unexpected behavior http://use.perl.org/~phillup/journal/21817?from=rss <p>I'm experiencing behavior that was not expected, and I'm wondering if this is "normal".</p><p>I have a "session" object that has a "has a" relationship with CGI::Session.</p><p>If I make sure to undef my object before the program ends, then everything is fine.</p><p>However, if I don't specifically undef my session object... and instead rely on the default garbage collection... it looks like the CGI::Session object I'm using gets destroyed BEFORE my session object gets destroyed.</p><p>It would seem to me that there should still be a reference count to the CGI::Session object as long as my object exists and that my session object would be destroyed first. Isn't this the way it is supposed to happen?</p><p>I managed to squeak out a diagnostic message that said</p><blockquote><div><p> <tt>DESTROY created new reference to dead object</tt></p></div> </blockquote><p>and have litterd my code with diagnostic print statements. Everything is fine until I make a call to the CGI::Session's param method and then the program spits out:</p><blockquote><div><p> <tt>Can't call method "param" on an undefined value...</tt></p></div> </blockquote><p>I am about to write a "minimal" object to try and replicate (and hopefully fix) the problem. But, I was wondering if I'm just totally mixed up on Perl's garbage collection.</p><p>TIA</p><p>---</p><p>UPDATE: By adding a print statement to my destructor and the destructor in CGI::Session I can definitely say that CGI::Session is being destroyed before my object is.</p><p>---</p><p>UPDATE 2: I've <a href="http://use.perl.org/~phillup/journal/21827">posted</a> code that demonstrates the problem in a new journal entry.</p> phillup 2004-11-11T21:16:26+00:00 journal Political Results http://use.perl.org/~phillup/journal/21728?from=rss <p>I saw <a href="http://www.esri.com/industries/elections/graphics/results2004_lg.jpg">this picture</a> which was linked to from a <a href="http://politics.slashdot.org/article.pl?sid=04/11/05/1334229&amp;tid=226&amp;tid=103">slashdot article</a>.</p><p>I'm sure it is all about point of view, but... it looks to me like small signs of civilization in a vast waste land.</p><p>Tho, I do think the picture is "rigged". The color used to indicate the republican votes does not show relief very well. At first glance the "red" vote looks pretty flat. You have to look really hard to see the *shadows* from the raised levels.</p><p>If you look at the shadows (for both red and blue) you start to notice something very strange... they are all on the "eye" side! So, looking west you see the shadow side of the raised features... and, looking east also shows you the shadow side.</p><p>That is not right.</p> phillup 2004-11-05T16:00:20+00:00 journal How do you install modules? http://use.perl.org/~phillup/journal/21097?from=rss <p>I was just reading <a href="http://use.perl.org/~rafael/journal/21089">a post by rafael</a> and it got me thinking about something that I've been wondering about a for a long time.</p><p>Mainly, installing Perl modules from a vendor vs. installing via CPAN.</p><p>For myself, I usually install almost everything via CPAN... because they don't get updated during normal system updates. That way I've got a chance to run updates on a dev server (and my test scripts) before they make it into production.</p><p>In some cases I actually recompile a custom Apache and (mod)Perl specifically so that system updates don't fubar what I've written. (OSX is one such case. The vendor version(s) don't like Mason that well. Panther is better, but I've had problems that were resolved by compiling custom versions.)</p><p>Now, one obvious downside is when there might be a serious data damaging (or security) issue... and I haven't kept things up to date.</p><p>So... how do others handle module installs? Do you do everything one way... like always use the vendor version unless there isn't one.... a mixture, like installing everthing that requires a compiler using the vendor modules and the rest from CPAN... or is it less "planned" than that?</p><p>TIA</p> phillup 2004-09-28T23:19:46+00:00 journal Just Me? http://use.perl.org/~phillup/journal/20825?from=rss <p>Is it just me, or:</p><p>1) Did slashdot get a bit slower since putting in the politics section?</p><p>and</p><p>2) Was anyone else a bit less productive this week?</p> phillup 2004-09-11T00:12:23+00:00 journal cheap profiler http://use.perl.org/~phillup/journal/20397?from=rss <p>Well, there was an interesting side effect of parsing my web logs to identify all the places where I'm throwing warnings.</p><p>I've got a relative count of how many times the code is being called. Of course, it is only the code that causes warnings that is being counted...</p><p>Anyways, this is my most troublesome snippet, accounting for 80 percent of the current warnings.</p><blockquote><div><p> <tt>&nbsp; $form<nobr> <wbr></nobr>.= $args-&gt;{'hidden'};<br>&nbsp; $form<nobr> <wbr></nobr>.= '&lt;/form&gt;';</tt></p></div> </blockquote><p>This code builds forms, and has an optional parameter for hidden fields. If there are any hidden fields, they are added right before we close off the form.</p><p>It seems a bit much to have to say</p><blockquote><div><p> <tt>&nbsp; $form<nobr> <wbr></nobr>.= $args-&gt;{'hidden'} if $args-&gt;{'hidden'};</tt></p></div> </blockquote><p>When the original code "Does The Right Thing".</p><p>Also, 100% of the errors have to do with string concatenation, or comparison operators where I expect that values may be 'undef'.</p><p>So... I'm about to spend a lot of time eleminating warnings that are "harmless". Because, even with all my bitching... I know that there will be a payoff... eventually.</p> phillup 2004-08-13T18:29:57+00:00 journal Interesting reaction http://use.perl.org/~phillup/journal/20396?from=rss I'm a lurker. There, I've said it. I watch, I listen (or read, as the case may be) and, on the really good days... I learn. I read a <a href="http://use.perl.org/~merlyn/journal/20392">post</a> by Randall and went to have a <a href="http://www.perlmonks.org/index.pl?node_id=382567">look for myself</a>. I'm not sure what it will look like later, hopefully it will change. But, right now there are big black boxes where all of the code is. You can, of course, hilite the code with your cursor and read every thing. But, this reaction... the blocking out of the code, is really disturbing to me for several reasons. <ul> <li>The nature of "open source" is that code be available. Technically, it still is. But, an effort has been conciously made to make this code less so. I'm not sure what bothers me more... that it was done in the first place, or done so inneffectively. (After reading the node again, it seems that the individuals are blacking out their own code, if they wish. That isn't *quite* as disturbing...)</li><li>It is a community site. The nature of the community is one of the things I like about Perl. It isn't just a language. That nature, for the most part is one of openness and sharing. Yet, this doesn't seem to be very open like.</li></ul><p> I've read in <i>Perl Medic</i> that to reach the highest level you will need to take part in "Perl obfuscation"... I sincerely hope this doesn't qualify.</p> phillup 2004-08-13T17:52:02+00:00 journal Dreaming about warnings http://use.perl.org/~phillup/journal/20395?from=rss <p>Andy just posted that he <a href="http://use.perl.org/~petdance/journal/20393">dreams about Perl people</a>.</p><p>Last night I dreampt about Andy, or... more specifically, about what <a href="http://use.perl.org/comments.pl?sid=21949&amp;cid=33343">he wrote</a>.</p><p>I've had my head buried in the (formal) tests for a bit now. Trying desperately to catch up and put some automated testing in place for code I've been writing for two years. It is a lot of code and writing (legitimate) tests for all of it is going to be huge.</p><p>That's the price of sin I guess...</p><p>Anyways... I took his comment to be talking about my tests. It dawned on me during the night that I have warnings in my web server logs...</p><p>Andy said: <i>Do NOT ignore warnings.</i></p><p>I heard: Do NOT ignore warnings <i>in your tests</i>.</p><p>I'm not sure if that is what he meant. Probably not.</p><p>Either way, the nugget of knowledge is: <b>Do NOT ignore warnings.</b> But, I've been doing just that... ignoring the warnings in the web logs.</p><p>So, today I will be spending some time looking thru the server logs and trapping warnings.</p><p>I'm a bit slow at times, but I like to think I can still learn a trick or two.</p><p>Thanks Andy!</p> phillup 2004-08-13T15:37:07+00:00 journal Perl Stumblings http://use.perl.org/~phillup/journal/20385?from=rss <p>While googling for some info on hashes in scalar context I stumbled upon <a href="http://www.sanbi.ac.za/tdrcourse/material/perl/lectures/3_arrays_and_hashes/index.html">this page</a>.</p><p>Playing with the URL a bit got me <a href="http://www.sanbi.ac.za/tdrcourse/material/perl/lectures/">here</a>.</p><p>And clicking on the last link got me <a href="http://www.sanbi.ac.za/tdrcourse/material/perl/perl5.html">this page</a> which I immediately bookmarked.</p> phillup 2004-08-12T23:40:10+00:00 journal Warning Will Robinson http://use.perl.org/~phillup/journal/20384?from=rss <p>So, about a month ago I got all into writing test code for my modules. But, we are talking a *LOT* of code... so, I'm spending an hour or so a day to write tests of the existing code... and the rest of the day I write tests before writing new code.</p><p>I figure I'll get caught up an a year or two.</p><p>;-)</p><p>Anyways... one of the test that I wrote checked each module file (and all of my maintenance scripts) for 'use warnings'.</p><p>So, it took a day to fix all of the files and the warnings... proof positive of the need for unit testing.</p><p>Still, since I'm starting so late in the process and taking a 'piecemeal' approach to getting full test coverage (that'll be the day!)... I'm coming across many places where I get a particular warning:</p><blockquote><div><p> <tt>Use of uninitialized value in...</tt></p></div> </blockquote><p>Now, one hundred percent of the time (so far) that I have gotten the warning, my code has been "reasonable". In other words... there were not any "unintentional" use of the variables. For example:</p><blockquote><div><p> <tt>my $sum;<br>foreach (keys %scores){<br>&nbsp; $sum += $scores{$_};<br>}</tt></p></div> </blockquote><p>Will trigger the warning, since I'm using sum without explicitly setting the value to zero before hand. But, this is Perl, and I know that it will do that for me. And... I'm lazy. Worse, I don't see the need to do it twice (once by Perl, once by me).</p><p>And, since I believe that any variable that is lexically scoped via 'my' should be considered initialized... that is just salt in the wound to me.</p><p>So... I've been wrapping those small chunks in their own blocks and doing the 'no warnings "uninitialized"' thing... But... I'm leaning towards simply making that the default for the entire module(s).</p><p>Are there any warnings that you or your company ignore as "standard practice"?</p><p>And, of course, what are the pitfalls of doing so...</p> phillup 2004-08-12T23:25:28+00:00 journal