kellan's Journal kellan'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:31:02+00:00 pudge Technology hourly 1 1970-01-01T00:00+00:00 kellan's Journal Improving CPAN's RSS feed? <p> So who would one talk to about improving CPAN's RSS feed of <a href="">recent uploads?</a> </p><p> It seems silly that at the very least the feed doesn't include the short descriptions visible on the <a href="">recent upload page.</a> </p><p> From there we could go on to a feed that included the full pod, pointers to the Changes and README files, the related modules info, etc... </p><p> We've got the metadata, lets use it. </p><p> Writing this journal entry probably took as long as writing a scraper would have, but hopefully it will lead to better things. </p> kellan 2003-03-01T17:23:58+00:00 cpan Why doesn't XML::RSS encode entities? <p> Why doesn't XML::RSS encode entities automatically when outputting XML? (or with a flag?) If I parse an RSS file with XML::RSS I get a nice datastructure out that I can tweak and play with, but if I want to pass that datastructure back into XML::RSS I have to worry about walking the mess of nested hashes, and re-encoding every stray ampersand. </p><p> Not so hard you say? True. Simply in fact. I can cut and paste lines 658 thru 897 out of XML::RSS and into my script, and then add a handful of calls to encode(). Somehow though, cutting and pasting 240 lines into my script seems the wrong way to go. </p><p> Is there a logic behind this that I'm missing? In general its a very nice module, and I feel like maybe I'm over looking a perfectly valid reason for building a tool that encourages broken XML. </p><p> Any insights appreciated. Thanks. </p> kellan 2002-07-29T01:07:30+00:00 journal Mail::Mailer, and the frustrating From header I wrote up a little script using Mail::Send. Mail::Send doesn't explicity have a from() method, but $msg-&gt;set('From', '') works fine. Or at least it worked fine on my laptop. However when I moved the same script to my server, I mail was now being sent out from ''. <p> I was puzzled. I tried making apache a trusted Exim user, double checked that was acknowledged as a local domain, etc, etc. In mounting frustration I was tempted to throw it all out, and revert to the bad old days of talking to sendmail (well Exim in sendmail clothing) directly. </p><p> Then it hit me, Mail::Send is using Mail::Mailer under the covers, Mail::Mailer first attempts to send mail out using the unix mail program, and then falls back on using sendmail. </p><p> My laptop doesn't have mail installed, the server does. </p><p> So if I change: <code>$fh = $msg-&gt;open(); # $msg is an instance of mail send</code> <br>to<br> <code>$fh = $msg-&gt;open('sendmail');</code> </p><p> Now everything works like a charm. </p><p> I mention this here, because surprisingly a quick google search turned up no mentions of anyone ever running into a similiar problem. So hopefully the next person (assuming anyone else is as slow) will stumble across this.</p> kellan 2002-03-01T06:56:17+00:00 journal Exceptions, Exception::Class, and a quick hack I've just recently returned to the land of complex Perl applications after many years wandering in foreign climes. And while it feels good to be back, I sorely miss some of elements of those exotic cultures. For example, exceptions. <p> So, surpised, and very happy, was I to find, clean of interface, with a nicely developed try/catch syntax.(plus an otherwise keyword, which I forcely ignored) </p><p> However it was not to be. Dire were the warnings against and its memory leaks. </p><p> So I've started playing with Exception::Class. While it does not have the comfortable familiarity of an old friend that had, it comes reccomended, and with some of its one pleasures. </p><p> But, I'm stuck using the</p><blockquote><div><p>eval {}; if ($@)</p></div></blockquote><p> syntax, which is, for all intents and purposes new to me. </p><p> And I hit a <b>snag.</b> </p><p> See, my code would be merrily executing along, and then throw some nice, explicitly named execption like:</p><blockquote><div><p>throw RW::Exception::App::BadPassword();</p></div> </blockquote><p> Now I don't feel any need to pass an error message to this throw, the name of the exception makes clear what it does.(its self-documenting<nobr> <wbr></nobr>;) </p><p> However when I go to catch it, with some code like:</p><blockquote><div><p>if ($@ and $@-&gt;isa('RW::Exception::App::BadPassword') )</p></div> </blockquote><p> the first test fails. And it fails because Exception::Class overloads stringification. </p><p> Exception::Class's as_string method returns the error you passed to throw (nada in my case) and possibly the stack trace. (which I didn't have enabled) So when I tested for the existence of an exception, I was testing the <b>truth value</b> of an <b>empty string.</b> </p><p> So after 30 frustrating minutes of wondering why my exceptions where disappearing into thin air, I overrode Exception::Class's as_string with my own:</p><blockquote><div><p>sub as_string {</p><blockquote><div><p>my $self = shift;<br> my $str = Exception::Class::Base::as_string( $self );<br> my $name = ref($self);<br> return "$name: $str";</p></div> </blockquote><p> }</p></div> </blockquote><p> Now all my exceptions test true. Yeh. 30 minutes to debug, 5 minutes to code, and 20 minutes to write a usePerl journal entry, leaving 5 minutes to grab a cup of coffee, and make a well spent hour.</p> kellan 2002-01-29T04:15:50+00:00 journal