jdavidb's Journal http://use.perl.org/~jdavidb/journal/ jdavidb'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-25T01:46:32+00:00 pudge pudge@perl.org Technology hourly 1 1970-01-01T00:00+00:00 jdavidb's Journal http://use.perl.org/images/topics/useperl.gif http://use.perl.org/~jdavidb/journal/ Cute caps http://use.perl.org/~jdavidb/journal/40507?from=rss <p>I'm doing some quick code generation (the output is Java), and I found myself writing the below routine. I like it because of the names I picked for the variables. Not exactly self-documenting (although it is when you think about it), but this is throwaway. You can probably tell what the code is doing and why I named the variables as I did, and you might be entertained.</p><blockquote><div><p> <tt>sub uc_prop<br>{<br>&nbsp; my($prop) = @_;<br>&nbsp; my $p = substr($prop, 0, 1);<br>&nbsp; my $P = uc($p);<br>&nbsp; my $rop = substr($prop, 1);<br>&nbsp; return "$P$rop";<br>}</tt></p></div> </blockquote> jdavidb 2010-08-19T21:55:41+00:00 journal Strawberry Perl install rolled back http://use.perl.org/~jdavidb/journal/40462?from=rss <p>Strawberry Perl 5.12.0 was almost completely installed when suddenly it flashed some message I didn't see into the install wizard and the progress bars started moving backward! I have never seen anything like it. I realized the progress bar caption had been changed to simply "Rolling Back Action" and watched as at least three anonymous "actions" were rolled back, progress bar by progress bar. Then the install wizard simply told me "Strawberry Perl Setup Wizard ended prematurely Strawberry Perl Setup Wizard ended prematurely because of an error. Your system has not been modified. To install this program at a later time, run Setup Wizard again. Click the Finish button to exit the Setup Wizard."</p><p>I wish it would tell me what the error was so I might have some hope of correcting it.</p> jdavidb 2010-07-26T20:34:33+00:00 journal Hiveminder: personal RT, for free http://use.perl.org/~jdavidb/journal/40452?from=rss <p>You mean someone will provide RT for me to use for free on the web? And they've built an awesome AJAX-y frontend for it? And they allow me to tag tasks and they encourage me to keep my work todo list and as many personal todo lists as I want in here? And they give me awesome search utilities for figuring this out and keeping it organized?</p><p>It's almost like <a href="http://hiveminder.com/">a dream come true</a>.</p> jdavidb 2010-07-19T16:58:36+00:00 journal Strawberry Win32 GUI programming http://use.perl.org/~jdavidb/journal/40388?from=rss <p>If I wanted to write a Strawberry program to run as a daemon and periodically pop up alerts on my machine, and I had no Windows Perl GUI programming experience other than an abortive look at WxPerl years before anybody ever thought of Strawberry, what module would I be looking for?</p> jdavidb 2010-06-09T15:10:53+00:00 journal Another StackOverflow question moved: what's the deal? http://use.perl.org/~jdavidb/journal/40357?from=rss <p>Stack Overflow is made significantly less useful when ignorant people move Perl programming questions to serverfault.com because the questions are about <a href="http://stackoverflow.com/questions/2769078/perl-tds-character-sets-closed">"servers, networks or the administration of many machines."</a>.</p><p>This kind of ridiculous micromanaging by people who are awarded points for being anti-helpful is what destroyed Wikipedia as a place I wanted to participate.</p> jdavidb 2010-05-20T14:18:10+00:00 journal Testing gurus, would you please chime in? http://use.perl.org/~jdavidb/journal/40346?from=rss <p>The question is how to test a class that installs system services: <a href="http://stackoverflow.com/questions/2790072/unit-testing-installation-of-services">http://stackoverflow.com/questions/2790072/unit-testing-installation-of-service<nobr>s<wbr></nobr> </a> </p> jdavidb 2010-05-07T17:16:23+00:00 journal Ball of mud song http://use.perl.org/~jdavidb/journal/40317?from=rss <p>Anyone got any good songs about working on a ball of mud?</p> jdavidb 2010-04-20T15:01:23+00:00 journal From UTC to US/Central http://use.perl.org/~jdavidb/journal/40287?from=rss <p>I've been living on UTC time since just before the end of Daylight Saving Time, 2005. Today I have reset my workstation to Central time. It's like looking at the world with fresh eyes.</p><p>My settings on websites will follow at some point.</p> jdavidb 2010-04-01T17:57:23+00:00 journal RIP Jaime Escalante http://use.perl.org/~jdavidb/journal/40282?from=rss Jaime Escalante, America's best math teacher, passed away last night. Escalante built a spectacular mathematics program in a struggling inner-city school district, teaching disadvantaged children all the way through Advanced Placement Calculus. His story was depicted in the 1988 film Stand and Deliver. I've got to say this man was really one of my personal heroes. When Sarah and I started talking about homeschooling our children it was thoughts of Mr. Escalante that made me get really serious about the kind of education our children could have with us directing. jdavidb 2010-03-31T12:43:26+00:00 journal Things I didn't know about the Walls http://use.perl.org/~jdavidb/journal/40254?from=rss <p>Larry's son, Lewis, is writing a 2D game engine in Perl 6 using Rakudo (<a href="http://www.wall.org/~lewis/">http://www.wall.org/~lewis/</a>).</p><p>Larry's wife, Gloria, took the Revised Common Lectionary and expanded it to make a complete Bible reading program which covers the entire Bible in three years (<a href="http://www.wall.org/~gloria/lect/">http://www.wall.org/~gloria/lect/</a>). And I wonder if maybe I'm not the only person in history who's ever written a program in Perl to divide up the Bible for reading, after all...</p> jdavidb 2010-03-19T17:00:01+00:00 journal Perl 10.1.0 doesn't build on Cygwin http://use.perl.org/~jdavidb/journal/40101?from=rss <p>Is building on Cygwin not supported any more, I take it? Did we forget about it?</p><blockquote><div><p> <tt>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CCCMD =&nbsp; gcc -DPERL_CORE -c -DPERL_USE_SAFE_PUTENV -U__STRICT_ANSI__ -<br>fno-strict-aliasing -pipe -I/usr/local/include&nbsp; -O3 -Wall -W -Wextra -Wdeclarati<br>on-after-statement -Wendif-labels<br>PATH=/home/dblackstone/perl-5.10.1:.:/home/dblackstone/bin:/hom<nobr>e<wbr></nobr> <nobr> <wbr></nobr>/dblackstone/bin<br>:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/cygdrive/c/Prog<nobr>r<wbr></nobr> am\ Files\ (x86)/J<br>ava/jdk1.6.0_16/bin:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/<nobr>c<wbr></nobr> ygdrive/c<br>/WINDOWS/System32/Wbem:/cygdrive/c/Program\ Files\ (x86)/ZipGenius\ 6/:/cygdrive<br>/c/Program\ Files/MySQL/MySQL\ Server\ 5.1/bin:/cygdrive/c/apache-ant-1.7.1/bin:<br>/cygdrive/c/Program\ Files\ (x86)/Git/cmd:/cygdrive/c/Program\ Files\ (x86)/cvsn<br>t:/cygdrive/c/Program\ Files\ (x86)/PuTTY:/cygdrive/c/Program\ Files\ (x86)/GnuW<br>in32/bin:/cygdrive/c/strawberry/c/bin:/cygdrive/c/strawberry/perl/b<nobr>i<wbr></nobr> n:/cygdrive/<br>c/Program\ Files\ (x86)/QuickTime/QTSystem/:/usr/lib/lapack:/usr/local:/etc:/usr<br>/lib:/lib:/sbin<nobr>:<wbr></nobr> <nobr> <wbr></nobr>/usr/sbin:/usr/libexec gcc -Wl,--enable-auto-import -Wl,--export<br>-all-symbols -Wl,--stack,8388608 -Wl,--enable-auto-image-base -L/usr/local/lib -<br>o miniperl.exe \<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;malloc.o gv.o toke.o perly.o pad.o regcomp.o dump.o util.o mg.o ree<br>ntr.o mro.o hv.o av.o run.o pp_hot.o sv.o pp.o scope.o pp_ctl.o pp_sys.o doop.o<br>doio.o regexec.o utf8.o taint.o deb.o universal.o xsutils.o globals.o perlio.o p<br>erlapi.o numeric.o mathoms.o locale.o pp_pack.o pp_sort.o cygwin.o \<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; miniperlmain.o opmini.o perlmini.o -ldl -lcrypt<br>/bin/sh: -c: line 0: syntax error near unexpected token `('<br>/bin/sh: -c: line 0: `PATH=/home/dblackstone/perl-5.10.1:.:/home/dblackstone/bin<br>:/home/dblackstone<nobr>/<wbr></nobr> bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/cygdrive/c/P<br>rogram\ Files\ (x86)/Java/jdk1.6.0_16/bin:/cygdrive/c/WINDOWS/system32:/cygdrive<br>/c/WINDOWS:/<nobr>c<wbr></nobr> ygdrive/c/WINDOWS/System32/Wbem:/cygdrive/c/Program\ Files\ (x86)/Z<br>ipGenius\ 6/:/cygdrive/c/Program\ Files/MySQL/MySQL\ Server\ 5.1/bin:/cygdrive/c<br>/apache-ant-1.7.1/bin:/cygdrive/c/Program\ Files\ (x86)/Git/cmd:/cygdrive/c/Prog<br>ram\ Files\ (x86)/cvsnt:/cygdrive/c/Program\ Files\ (x86)/PuTTY:/cygdrive/c/Prog<br>ram\ Files\ (x86)/GnuWin32/bin:/cygdrive/c/strawberry/c/bin:/cygdrive/c/strawber<br>ry/perl/b<nobr>i<wbr></nobr> n:/cygdrive/c/Program\ Files\ (x86)/QuickTime/QTSystem/:/usr/lib/lapac<br>k:/usr/local:/etc:/usr/lib:/lib:/sbin<nobr>:<wbr></nobr> <nobr> <wbr></nobr>/usr/sbin:/usr/libexec gcc -Wl,--enable-au<br>to-import -Wl,--export-all-symbols -Wl,--stack,8388608 -Wl,--enable-auto-image-b<br>ase -L/usr/local/lib -o miniperl.exe \'<br>make[1]: *** [miniperl.exe] Error 2<br>make[1]: Leaving directory `/home/dblackstone/perl-5.10.1'<br>make: *** [install] Error 2</tt></p></div> </blockquote> jdavidb 2010-01-14T17:16:42+00:00 journal Stack Overflow career spam http://use.perl.org/~jdavidb/journal/40084?from=rss <p>I got a fairly innocuous spam from Stack Overflow advertising their new job hunting site, where they would like me to upload my resume.</p><p>Sorry, Stack Overflow; I'm <a href="http://www.asktheheadhunter.com/">smart for that</a> (thanks to Andy Lester). I also don't particularly appreciate the spam, although it's the first I've ever gotten and wasn't too obtrusive.</p> jdavidb 2010-01-07T15:26:00+00:00 journal SVK retired http://use.perl.org/~jdavidb/journal/40043?from=rss <p>I didn't notice, but SVK <a href="http://lists.bestpractical.com/pipermail/svk-devel/2009-May/001224.html">retired</a> in May. Thanks to its authors and Best Practical for providing it. I agree with the sentiment that people moved on from Subversion quicker than expected; I am glad that I went on to git instead of spending too much time with SVK, although I would've liked to have learned it earlier and gotten to know it better.</p> jdavidb 2009-12-21T22:00:29+00:00 journal 19100 all over again http://use.perl.org/~jdavidb/journal/40030?from=rss I just saw a website say "Today is: December 17, 109"<nobr> <wbr></nobr>:) jdavidb 2009-12-17T19:42:14+00:00 journal Instructions: in the middle of a git rebase conflict http://use.perl.org/~jdavidb/journal/39759?from=rss <p>So you've done a git rebase, and a conflict was reported.</p><p>The instructions you originally received (which have long since scrolled off your screen), were:</p><blockquote><div><p> <tt>Failed to merge in the changes.<br>Patch failed at 0051.<br> <br>When you have resolved this problem run "git rebase --continue".<br>If you would prefer to skip this patch, instead run "git rebase --skip".<br>To restore the original branch and stop rebasing run "git rebase --abort".</tt></p></div> </blockquote><p>Thankfully, I can usually remember the --abort switch.</p><p>What you haven't been told is:</p><p>To get a list of files with conflicts from git, instead of trying to use ack and stuff and picking up false positives:</p><blockquote><div><p> <tt>git status 2&gt;&amp;1 | grep 'needs merge'</tt></p></div> </blockquote><p>After correcting a file with a conflict:</p><blockquote><div><p> <tt>git add FILE</tt></p></div> </blockquote><p>After all the files are added, run a git --rebase continue, <i>without doing a git commit</i> (just in case there was any confusion, and there usually is, for me).</p><p>There are a number of other "in the middle of a git conflict" situations that I encounter, none of which are handled the same way, and I hope in time to produce a complete series of instruction cheat sheets for them.</p> jdavidb 2009-10-15T17:55:28+00:00 journal SO vote to reopen: protected visibility http://use.perl.org/~jdavidb/journal/39738?from=rss <a href="http://stackoverflow.com/questions/1545186/do-you-use-protected-visibility-closed">http://stackoverflow.com/questions/1545186/do-you-use-protected-visibility-clos<nobr>e<wbr></nobr> d</a> <p>Somebody give me some tips on how to reword this to make it a "real question."</p> jdavidb 2009-10-09T19:23:19+00:00 journal regex spelling http://use.perl.org/~jdavidb/journal/39670?from=rss People who think regex should be spelled regexp should be dragged out into the middle of the street and shot. jdavidb 2009-09-23T19:10:29+00:00 journal 9-9-9 http://use.perl.org/~jdavidb/journal/39602?from=rss <p>I guess I have to do this again. It's tradition.</p><p>Eventually, we are going to run out of these.</p><p>Have a special day, everybody.</p> jdavidb 2009-09-09T14:34:04+00:00 journal What's the deal with relative times? http://use.perl.org/~jdavidb/journal/39565?from=rss <p>It seems to be all the rage today for sites to give timestamps only in an approximate, relative fashion: one hour ago, two days ago, etc. Among other sites, I see both Twitter and StackOverflow doing this, so apparently it's popular for both the technical and the general communities.</p><p>I can't figure out why. It's annoying to see two posts marked "one hour ago" and wonder which one was posted first. It's particularly annoying to see two posts marked "one hour ago," then check back and see that suddenly they are an hour apart, because one of them was "two hours ago" and the other is still "one hour ago," then to see them both finally mysteriously become "two hours ago."</p><p>Are real timestamps actually that hard for normal people to understand? Am I the only one in the world who ever wants to know if two posts are a five minutes or fifty-five minutes apart?</p><p>My favorite message board is hosted on UBB.threads (not my favorite software, but the community is good), which I think gives the user a profile option to disable this inanity. I can't find that on Twitter, and I'm about to check Stack Overflow, where I bet I won't find it, either.</p><p>Who thought this was a good idea? Who decided it shouldn't be a per-user option? And why in the world is everyone copying it?</p> jdavidb 2009-09-01T15:53:51+00:00 journal Environment variables are not programming-related http://use.perl.org/~jdavidb/journal/39522?from=rss <p>It must be true. Stack Overflow <a href="http://stackoverflow.com/questions/1313472/why-cant-windows-handle-an-environment-variable-in-path-closed">says so</a>.</p> jdavidb 2009-08-24T13:52:30+00:00 journal Can I Inline .NET? http://use.perl.org/~jdavidb/journal/39108?from=rss <p>Anyone know how to call<nobr> <wbr></nobr>.NET code from Perl?<nobr> <wbr></nobr>:)</p> jdavidb 2009-06-09T21:38:06+00:00 journal Java gravel of the day: substring redux http://use.perl.org/~jdavidb/journal/39003?from=rss <p>On 2008-01-25 I <a href="http://use.perl.org/~jdavidb/journal/35489">reported that Java's substring() method was brain damaged.</a> On 2008-02-22, I reported that apparently I had been brain-damaged and that Java seemed to be fine and work in a sane manner.</p><p>Today I'm looking at the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html#substring(int,%20int)">documentation</a>, and I've coded a test implementation, and as near as I can see the brain-damage that I reported really is present. Give Java a second index that goes beyond the length of the String, and instead of just getting the remainder of the String regardless of its length, you get a RuntimeException. If you want to say "Give me 9 characters, or however many you've got," you get to do some math on that yourself. I hope you don't commit a fencepost error.</p><p>Here's my implementation that demonstrates this:</p><blockquote><div><p> <tt>public class Substr {<br>&nbsp; private String str;<br> <br>&nbsp; public Substr(String str) {<br>&nbsp; &nbsp; this.str = str;<br>&nbsp; }<br> <br>&nbsp; public String substr(int beginIndex, int endIndex) {<br>&nbsp; &nbsp; return str.substring(beginIndex, endIndex);<br>&nbsp; }<br> <br>&nbsp; public static void main(String[] args) {<br>&nbsp; &nbsp; String str = args[0];<br>&nbsp; &nbsp; int beginIndex = Integer.valueOf(args[1]);<br>&nbsp; &nbsp; int endIndex = Integer.valueOf(args[2]);<br>&nbsp; &nbsp; Substr substr = new Substr(str);<br>&nbsp; &nbsp; System.out.println(substr.substr(beginIndex, endIndex));<br>&nbsp; }<br>}</tt></p></div> </blockquote><p>Run results look like this:</p><blockquote><div><p> <tt>$ java Substr ABCDE 0 1<br>A<br>$ java Substr ABCDE 0 2<br>AB<br>java SubStr ABCDE 0 9<br>Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 9<br>&nbsp; &nbsp; &nbsp; &nbsp; at java.lang.String.substring(String.java:1765)<br>&nbsp; &nbsp; &nbsp; &nbsp; at Substr.substr(Substr.java:9)<br>&nbsp; &nbsp; &nbsp; &nbsp; at Substr.main(Substr.java:17)</tt></p></div> </blockquote><p>I really just don't think that this is good design. But maybe I'm prejudiced. When I'm coding in something besides Perl, I don't expect the benefit of things like negative indices, but I do expect some sanity. To my way of thinking, substr(pos, len), returning up to len characters but not necessarily that many if they are not available, is a pretty common way for languages to specify this call, and is objectively better than substr(start, end + 1) or substr(start, end), and definitely better than throwing an exception for a length too long. But is this really objectively so?</p><p>Submitted the question for discussion on <a href="http://stackoverflow.com/questions/883638/how-should-substring-work">Stack Overflow</a>, so we'll see how that goes.</p><p>I looked at the source for Java 5's String class and was impressed with the efficiency of the implementation of substring(). Internally a String keeps a char[] array and an offset telling where the String starts in that array; a private constructor permits substring() to return a new String that <i>shares</i> the char array with a new offset and length, which seems quite efficient and clever, to me. But I can see that a sane substr() would have been quite easy to implement using the same constructor; in fact, a new substr() could be grafted on with Perl's semantics (probably including negative indices) with hardly any trouble at all and no conflict with the existing substring() since the name is different.</p><p>I have only a slight idea as to why I rescinded my initial false report: I may have been looking at the other signature for substring(), which takes only one index and returns characters through to the end of the String. That's good behavior, as far as I'm concerned; I'd hate to have to work around it not being there.</p> jdavidb 2009-05-19T16:25:37+00:00 journal I'll journal about it if I want to http://use.perl.org/~jdavidb/journal/38935?from=rss <p>In fact, I might even blog.</p><p>I am tired of seeing folks gripe and moan about people who write journal entries about problems rather than sending in bug reports or contacting people directly.</p><p>People who write a post about a problem, no matter how friendly, are often subjected to vitriolic hatred, sometimes including swearing, and an attempt to shame and pressure them by appealing to some sense of "community interest." It never seems to occur to these folks that the journalists have their own interests to look out for. Maybe the journalist didn't want to serve the community for free. Maybe the journalist was simply making a note for himself. Maybe he would've filed a bug report later, when the problem was better understood. Maybe he thought the problem was his and someone would correct him in a forum and didn't think a bug report was appropriate. Maybe he's just making a record of obstacles he encountered. Maybe they simply disagree with you on what is and is not best discussed in public versus in private.</p><p>Plus, many folks seem to take this as a personal affront. Indeed "community interest" is often just an abstract notion used to shame people into supporting the speaker's interest. Cussing somebody out for writing a journal entry on use Perl instead of contacting you personally or filing a bug report or whatever else you would prefer them to do is nothing more than an attempt to shame them into acting as if they were your private slave. Don't expect people to take your interests into account if you have so little respect for their interests. And don't count on all the other individuals in the "community" to back up your bad behavior; some of us see through this crap for what it is, and don't enjoy watching it.</p><p>If two people are going to be "community" together, then it needs to be completely voluntary on both parts, and both people need to find that the relationship benefits them and enhances their goals. When a bunch of people do that in a network, it's a community, and the community is never a real thing; it's just an abstract term that refers to a giant asymmetrical network of relationships composed of individuals, each of whom has their own unique goals and desires, some but not all of which coincide at various times.</p><p>Politely notifying somebody that there's a bug reporting avenue they might not have been aware of is innocuous and often useful. Cussing somebody out for embarrassing you by blogging about how hard it is to understand your poor module documentation instead of emailing you privately just shows what a jerk you are. Don't kid yourself by pretending you are serving the "community." What you are really doing is emotionally injuring one node of the network that is your "community" in an attempt to serve your own vision of what everybody's interests should be.</p><p>Not everybody has to care about every journal entry. The author does, and that's enough. Not every journal entry has to find its way back to your version of the "interested parties." Sometimes a communicator feels better served by broadcasting instead of using point-to-point communication. If you pick up a broadcast and feel that it doesn't serve your needs as a listener, either quit listening, or take your own advice and politely contact the broadcaster if you think the two of you can work together to better meet each other's needs.</p> jdavidb 2009-05-07T14:03:46+00:00 journal Bad download archive hall of shame: Quartz http://use.perl.org/~jdavidb/journal/38906?from=rss <p>Major projects like <a href="http://www.opensymphony.com/quartz/">Quartz</a>, the Java enterprise job scheduler, should know that the package you download from their site should contain <b>one</b> top-level directory, so that when you extract it you get one quartz/ directory containing the contents of the archive, instead of dropping files like readme.txt and directories like docs/ and src/ everywhere, when you might already have files and directories with these names.</p><p>Shame on you, Quartz. Everybody else knows this by now.</p> jdavidb 2009-05-01T16:59:15+00:00 journal Setting up mysql client on Cygwin http://use.perl.org/~jdavidb/journal/38844?from=rss <p>I'm running Windows MySQL server, but I'm doing an increasing amount of my development work from Cygwin (thankfully). Unfortunately, to get maximum benefit out of Cygwin I want to be doing my work from xterms, and the Windows MySQL client expects to run under the Windows console. I really don't want to launch Windows consoles with Cygwin bash just for MySQL (or anything else, for that matter), and I don't want to limit myself to CMD, so I wanted to use a Cygwin-native MySQL client.</p><p>To compile the client, I had to pass --without-server and --without-libedit to<nobr> <wbr></nobr>./configure . The first option's meaning is obvious. The second seems confusingly-named to me: it directs MySQL to compile using libedit already installed on the system instead of compiling libedit from source bundled in its source tree. The option does not mean you won't get command-line history or anything. In fact, command-line history works beautifully and is much more preferable to what I get from the Windows MySQL client.</p><p>After installation, the client wants to connect through a local socket. I doubt that this can be made to work from Cygwin to Windows MySQL server, but I suppose it might be as simple as needing to direct the client to look for the socket somewhere besides<nobr> <wbr></nobr>/tmp/mysql.sock (C:\cygwin\tmp\mysql.sock) or making a symlink. My approach instead is to tell the client to connect with TCP:</p><blockquote><div><p> <tt>mysql --protocol=tcp</tt></p></div> </blockquote><p>This of course is inconvenient to type every time, so I put it in ~/.my.cnf . (I used strace on the failing mysql client to determine the potential locations for my.cnf were:<nobr> <wbr></nobr>/etc/my.cnf,<nobr> <wbr></nobr>/etc/mysql/my.cnf,<nobr> <wbr></nobr>/usr/local/etc/my.cnf, and $HOME/.my.cnf<nobr> <wbr></nobr>.) The my.cnf syntax is:</p><blockquote><div><p> <tt>[client]<br>protocol=tcp</tt></p></div> </blockquote><p>Googling revealed that it was also possible to force the client to connect with tcp by telling it to use 127.0.0.1 as the host. Mysteriously, this does not work when the host is specified as localhost.</p> jdavidb 2009-04-22T14:38:08+00:00 journal Carp in Java? http://use.perl.org/~jdavidb/journal/38769?from=rss <p>Does anyone know how to carp in Java? I'm writing a die() function which does some logging and other things and is supposed to throw an Exception, but since the Exception gets created within die() it reports die() as part of its stack trace, confusing anyone looking at it.</p><p>I'm <a href="http://stackoverflow.com/questions/727628/how-do-i-throw-an-exception-from-the-callers-scope">asking</a> on StackOverflow, but the typical Java response is "Why would you want to do that?"<nobr> <wbr></nobr>:)</p> jdavidb 2009-04-07T21:24:27+00:00 journal Where's Perl Power Tools? http://use.perl.org/~jdavidb/journal/38692?from=rss <p>Google's top hit is <a href="http://sourceforge.net/projects/ppt/">Sourceforge</a>, which says as of 2004 the project can be found at <a href="http://ppt.perl.org/">http://ppt.perl.org/</a>, which is 404ed.</p> jdavidb 2009-03-24T14:19:35+00:00 journal How do you run ack with Strawberry http://use.perl.org/~jdavidb/journal/38674?from=rss <p>I've just introduced one of my more enlightened coworkers to ack. He thinks it'll replace Cygwin for him entirely, and possibly even his Linux box. Only problem is, he can't get it to run with Strawberry on Windows. He and I are both mainly UNIX-literate. What do we need to do to get this set up right?</p><p>(He tried editing the shebang line, but I knew that wouldn't work.)</p><p> <b>Update:</b> Answer: use Strawberry's cpan command to install App::Ack, and use the ack that comes with that. I'd still like to know how to make it work for the standalone ack, though, as I'd like to know how to do this for arbitrary Perl programs in general. Apparently I'm supposed to be able to do so with the PATHEXT variable and some other manipulation, but I can't quite figure it out.</p> jdavidb 2009-03-20T18:46:59+00:00 journal Java tip of the day: regex s///g (global replacement) http://use.perl.org/~jdavidb/journal/38537?from=rss <p>It's hideous, but I think it does the trick:</p><blockquote><div><p> <tt>public static String subst(String string, String regex, String repl) {<br>&nbsp; Pattern pat = Pattern.compile(regex);<br>&nbsp; Matcher m = pat.matcher(string);<br>&nbsp; StringBuilder sb = new StringBuilder();<br>&nbsp; int prevend = 0;<br>&nbsp; while (m.find()) {<br>&nbsp; &nbsp; int start = m.start(0);<br>&nbsp; &nbsp; int end = m.end(0);<br>&nbsp; &nbsp; String val = m.group(0);<br>&nbsp; &nbsp; sb.append(string.substring(prevend, start));<br>&nbsp; &nbsp; sb.append(repl);&nbsp;<nobr> <wbr></nobr>// sb.append(transform(val));<br>&nbsp; &nbsp; prevend = end;<br>&nbsp; }<br>&nbsp; sb.append(string.substring(prevend));<br>&nbsp; return sb.toString();<br>}</tt></p></div> </blockquote> jdavidb 2009-02-23T13:45:39+00:00 journal File::Find::Rule, follow up http://use.perl.org/~jdavidb/journal/38513?from=rss <p>The truth is after my previous journal entry I went on to write a program that just takes the output of UNIX find.<nobr> <wbr></nobr>:) But I didn't finish, and I got pulled off of that project until later, so when I come back I may do something else.</p><p>Contrary to popular belief, I did <b>not</b> conclude that File::Find::Rule was dead!!! Nothing of the sort! I saw the date, and thought "That looks odd," and decided to ask. And provoked a great little discussion to come back to, in the process.</p><p>I actually wondered if the truth wasn't "The module is doing so well nobody's seen a need to update it since then." But I also thought it was entirely possible that work had carried on under a different name, much as WWW::Mechanize took off from its predecessor module (whose name I don't even remember at this point, but whose author was Kirrily "skud" Robert, IIRC).</p><p>I am quite glad to see that ack's approach can be accessed through File::Next. I will probably look into that at some point.</p> jdavidb 2009-02-19T21:55:24+00:00 journal