ddick's Journal http://use.perl.org/~ddick/journal/ ddick'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:33:32+00:00 pudge pudge@perl.org Technology hourly 1 1970-01-01T00:00+00:00 ddick's Journal http://use.perl.org/images/topics/useperl.gif http://use.perl.org/~ddick/journal/ Packaging Perl with Wix http://use.perl.org/~ddick/journal/40491?from=rss <p>Just got home after giving a talk on <a href="http://perl.net.au/wiki/Melbourne_Perl_Mongers/Meeting_History_2010_08">packaging Perl applications for win32 platforms using WiX.</a> </p> ddick 2010-08-11T12:36:32+00:00 journal mod_perl, freetds and environment variables??? http://use.perl.org/~ddick/journal/40234?from=rss <p>I have a application written as CGI scripts that run under mod_perl mode via ModPerl::Registry or if anyone still uses it Apache::Registry. It also connects to a variety of databases, including Microsoft SQL Server via freetds.</p><p>Freetds can be controlled via a freetds.conf config file or environment variables.</p><p>I liked the idea of using the distros freetds libraries (actually, freetds contains the ct library, which is the only one that DBD::Sybase cares about) and i thought i could avoid the issues with me and everyone else writing to the freetds.conf file by using environment variables.</p><p>Which worked well until it ran in mod_perl</p><p>Then it died horribly</p><p>Turns out that controlling a C shared library via setting environment variables in perl is tricky in mod_perl</p><p>Just a note in case someone else tries configuring mod_perl to talk to SQL Server via environment variables</p><p>However, so long as you use the freetds.conf file, SQL Server and mod_perl get along fine...<nobr> <wbr></nobr>:)</p> ddick 2010-03-09T09:27:20+00:00 journal Browser based testing of your own code http://use.perl.org/~ddick/journal/39902?from=rss <p>For those of us engaged in developing/supporting a web application, testing seems to be an almighty pain.</p><p>The state of the art seems to be; put a massive investment into writing test cases in Tool X, which manages (sort of) Browser Y. However thanks mainly to mozilla and khtml, but really opera and explorer are just as capable here, we can never be really sure if someone isn't going to come up with a great new browser.</p><p>The moment someone comes out with a new product, the whole testing routine needs to be re-written, usually, completely from scratch. B/c i haven't seen a tool that automates konqueror, opera, explorer and mozilla. Certainly not for linux as well as windows. However, i think this should be possible.</p><p>First things first, the automation script should be able to start up the browser and control it. X11::GUITest and Win32::GuiTest provides the basics of being able to recognise a window and send keystrokes and mouse clicks to it, which should be enough.</p><p>Secondly, the automation program must be able to recognise the correct page to the page to send input to, by clicking the mouse or tabbing.</p><p>This is where each new browser needs to provide some initialisation data. By using HTTP::Daemon, some sort of ajax mechanism, the onfocus and onclick events and X11::GUITest/Win32::GuiTest, it should be possible to recognise how many tab presses to get the first form field on the page AND the exact offset to allow you to put the mouse over any desired element. Calculating each elements position can be achieved using offsetLeft, offsetTop and offsetParet, which i think are universally supported now.</p><p>Once this is done, we can take load the web application for testing into some incarnation of HTTP::Daemon, together with our testing code and launch the browser to point at the daemon.</p><p>Apologies to those frame haters out there but i think the testing code needs to create a couple of frames, one containing the web application and one containing the requests/responses from the testing code. b/c all the requests are coming from the same source (the HTTP::Daemon) as the web application, it should be possible to launch cross frame queries to interrogate the web application window for the position of say the "Submit" button or the "Description" text box, allowing the test code to then move the mouse over it and click it, or just to press tab the correct number of times.</p><p>Getting at the source of the current web application page can be done by interrogating the HTTP::Daemon for the page source.</p><p>At this point i think i have a fair chance of being able to implement a pretty interesting version of the WWW::Mechanize interface, but testing the css and javascript for all known or future browsers.</p><p>However, getting the time to do it might be a bit tough at the moment</p> ddick 2009-11-16T10:38:44+00:00 journal Devel::Cover and how to test inputs? http://use.perl.org/~ddick/journal/39695?from=rss <p>I've been experimenting with the awesome Devel::Cover, and while it's great fun to use it to improve my test suite, my code also tries very hard to validate all input sources.</p><p>Devel::Cover can tell me that the line</p><p> $a == $b ? 1 : 0 </p><p>has been executed and even that both halves of the condition have been executed, but it can't tell me that i haven't tested the case where $a isn't numeric.</p><p>I'm testing as much as i can think of, but i'm unwilling to bet that all inputs have been checked, and i can't think of a way to guarantee it</p><p>Which is considerably annoying, as a lot of these inputs wind up in a database and databases are very unforgiving about bad input</p><p>My test suite already parses the sql ddl statements, maps them to the correct classes and runs through null,min,max,max+1,min-1,etc tests for each field but can i guarantee that i've caught every instance in a large code base?</p><p>Probably not</p><p>And to look at it another way, does this matter?</p><p>And why the hell am i writing test cases to improve test suite coverage (58% and climbing! woohoo!) when i could be writing more features?</p> ddick 2009-09-30T00:50:12+00:00 journal Job Interview oddness http://use.perl.org/~ddick/journal/39645?from=rss <p>$work has been advertising for a new testing position and i've been doing the role of assessment of technical skills of the prospective employees.</p><p>i've been a bit surprised when interviewees reach into their bag, pull out a folder of paper and offer to show me documents from their previous/current job.</p><p>Part of me wants to enquire "So, how do you think your previous/current employer feels about you showing their internal policies and procedures to external parties, and are you going to show us the same courtesy if/when you leave us?"</p><p>I can't quite figure out how to say that without it sounding like "you've got 10 seconds to leave the building before i call the cops you thieving $#@&amp;!!!!!"</p><p>The other part of me is thinkin' "Maybe this is just me being paranoid/super-sensitive/dumb about trade secrets, and i should just get over myself"</p><p>Which certainly seems the case when i consult my co-workers.... i dunno, it just seems odd to me.</p> ddick 2009-09-18T04:35:47+00:00 journal Net::Ping, Time::HiRes and virus scanners http://use.perl.org/~ddick/journal/39303?from=rss <p>at $work, we've been timing tcp connections with Time::HiRes and we hit an interesting problem. Time::HiRes was returning ridiculously small times for the tcp ping, approx 1-2 milliseconds, when we knew the time should be approx 30 milliseconds.</p><p>After firing up that beautiful piece of software known as (?:ethereal|wireshark), we verified that the traffic actually took approx 30 milliseconds as expected.</p><p>turns out that the Web Shield portion of the AVG anti virus product filters among other things, tcp port 80, and this filtering process stuffs the Time::HiRes timings up.</p> ddick 2009-07-16T23:41:11+00:00 journal Melbourne.pm and lack of sleep http://use.perl.org/~ddick/journal/39114?from=rss <p>Had a small meeting last night, only about 10 people managed to make it as the weather was a little chilly and damp.</p><p>we discussed and approved of the idea of having group hacking sessions to work on perl modules in the fail100 list in a future meeting.</p><p>jarich also presented a talk on preparing abstracts (which seem to be actually "short descriptions" instead of an academic abstract) for conferences which was very interesting.</p><p>The talk was also delivered after only 3-4 hours sleep in the past 36. Personally, i'm fine to physically work in that state, but mental concentration just goes to pieces, so i was impressed. I had a bit of a chuckle at the occansional word transposition, but i was impressed</p> ddick 2009-06-11T00:42:30+00:00 journal UTF-8, perl and Microsoft SQL Server http://use.perl.org/~ddick/journal/39102?from=rss <p>Attempting to note things without going insane with frustration. SQL Server cannot handle UTF-8. It can however handle UCS-2 (great for windows or java programmers), but in a bizarre fashion.</p><ul> <li>First, char, varchar and text fields do not hold UCS-2 data. nvarchar, nchar and ntext do.</li> <li>Secondly, quoting of data is somewhat different. Instead of quoting data like so 'foo', it becomes N'foo'.</li><li>Now finally, when connecting with DBD::Sybase with underlying freetds libraries, you need to define "Client Charset = UTF-8" AND use the Encode module to encode your statement as 'UTF-8' before passing it to DBI-&gt;prepare.</li></ul><p>Salutations to the DBD::Sybase and freetds team for their excellent work in allowing perl to talk UTF-8 (at least the UCS-2 compat portion of it) to a database that doesn't even support it.</p><p>As a side note, i think that when constructing a test suite for a program that uses a database for a backend, it's essential to test the database itself for edge case conditions, such as in this case, making sure that you can fill a varchar(10) with ten three byte unicode characters AND retrieve it AND the retrieved value matches your expected result. Cos maybe your definitions are behaving slightly differently than you thought.</p> ddick 2009-06-09T00:49:22+00:00 journal Embedded databases and installable packages http://use.perl.org/~ddick/journal/38756?from=rss <p>I happen to like the idea of using cross database compatible SQL in my application code.</p><p>While this can produce somewhat horrific code (thank you Sybase for passing on to Microsoft the notion that only one query per database handle can be active at a time), most of the time i am happy with the extra planning trade off that allows customers to use a database that they are familiar with.</p><p>However, while testing a number of database backed packages of alternative products, it became horribly apparent how vital at least support for an embedded database is.</p><p>Because all i wanted to do is experiment with each application and see how it worked and if it matched with my needs.</p><blockquote><div><p> <tt>rpm -i $PACKAGE</tt></p></div> </blockquote><p>Point browser at url.</p><p><div class="quote"><p>Database error. unable to determine username / password to create database</p></div><p>Oh goody. Thank you for making me find and read the sys. admin. notes on how to reconfigure the application to use my pre-installed and locked down database.</p><p>This takes time. It's annoying b/c i have to evaluate a pile of these packages. By the time i am actually looking at the working product, i already hate it for wasting my time. B/c my job is not dealing with this package. The package just helps???? me do my job</p><p>Alternatively, if the installable package came including a pre-configured and instantly available SQLite database (possibly even with sample data in it) my first experiments with the package would have left me feeling much happier.</p><p>To be fair, any embedded product would probably be fine, including Embedded MySQL (which i've never used), it just needs to not depend on the user having a completely unsecured database installation to work.</p> ddick 2009-04-04T23:31:34+00:00 journal Melbourne.PM and frothing hatred of msi packages http://use.perl.org/~ddick/journal/38664?from=rss <p>This month we had a talk from Tony Smith on cellular automata, specifically on using Golly 2.0, a new tool for this type of work. My brain melted, but it looked awesomely cool. Little spaceships running around, consumers, generators, chaos, order.... </p><p> And despite previous vague approvals of the msi native packaging for win32 platforms, i now hate this mechanism. Blind frothing hatred. I do not understand how <a href="http://groups.google.com/group/microsoft.public.platformsdk.msi/browse_thread/thread/0ed21e239137c5f4">a packaging system explodes</a> b/c a package has over 1200 files (technically components, but "best practices" is one file per component) in it. </p><p>Agreed, it's a big package. But unable to cope with it?? Forcing the user to descend into the registry (/etc for unixers) to fix the corruption manually? No helpful messages even, unless you believe that a popup window saying "Error 2908" leads you to delete the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData<nobr>\<wbr></nobr> S-1-5-21-1123561945-1935655697-1060284298-1003\AD95649F068525549B26938D7D18FEA7 key</p> ddick 2009-03-19T05:14:04+00:00 journal Monthly Melbourne PM meeting http://use.perl.org/~ddick/journal/38300?from=rss <p>Good and bad news for this month's Melbourne PM meeting.</p><p>Good news, a record (for the new venue) number of mongers (25.5, including what seemed to be a 3 year old perl hacker<nobr> <wbr></nobr>:)) turned out to hear <a href="http://use.perl.org/~pjf/journal/">Paul</a> talk about App::Sweeperbot (funny, but uses the extremely useful Win32::GuiTest), Devel::NYTProf (awesome), PAR (remote repositories look very useful), moose and perl 5.10 regexps.</p><p>Bad news, i stuffed the airconditioning arrangements, so the meeting room got kinda warm. Hoping not to repeat that fiasco. Also, the quest to find a broadly acceptable place to eat/drink afterwards continues. Apparently the idea of booking a place to sit down and have a range of food and drink presented is harder than it should be. Targeting <a href="http://en.wikipedia.org/wiki/File:IMG_6338_Young_and_Jackson,_Melbourne,_Australia.jpg">Young &amp; Jacksons</a> as a test for next meeting.</p><p>Need to find time to check out the remote_repository stuff for PAR too. At the moment it's looking like it has the potential to fix the "how to i distribute updatable code to non-root users" problem.</p> ddick 2009-01-16T05:24:20+00:00 journal Multi-byte Unicode and PDF http://use.perl.org/~ddick/journal/37784?from=rss <p>After an excellent <a href="http://popcorn.cx/talks/beyond-ascii/">talk on the Encode module</a> by <a href="http://popcorn.cx/about/">Stephen Edmonds</a> and a close encounter with the &#181; symbol, i've been playing with the various unicode symbols a lot.</p><p>A missing component seems to be putting multi-byte unicode into a PDF document. Try this little beggar &#29399; on for size.</p><p> <a href="http://search.cpan.org/dist/PDF-API2/">PDF::API2</a>, <a href="http://www.htmldoc.org/documentation.php">htmldoc</a> and <a href="http://user.it.uu.se/~jan/html2psug.html">html2ps</a> all seem to have problems with characters when the encodings uses more than 1 byte to represent 1 character. </p><p>Anyone know a tool that can do the job?</p> ddick 2008-11-02T08:55:58+00:00 journal Modules for logging on win32 http://use.perl.org/~ddick/journal/37311?from=rss <p> <a href="http://use.perl.org/~acme/">acme</a> was <a href="http://use.perl.org/~acme/journal/37289">asking about best practice for logging modules</a>, citing <a href="http://search.cpan.org/~mschilli/Log-Log4perl-1.18/lib/Log/Log4perl.pm">Log::Log4Perl</a> and <a href="http://search.cpan.org/~drolsky/Log-Dispatch-2.21/lib/Log/Dispatch.pm">Log::Dispatch</a>. By preference and experience i'm a unix programmer, but recently (last couple of years) i've needed to write some stuff for the win32 platform. One of the more difficult things i've encountered is trying to log 'natively' on win32 and unix.</p><p>For me, native logging on win32 means logging to the windows event logger, which, as seen at <a href="http://search.cpan.org/~jdb/Win32-EventLog-0.076/EventLog.pm">Win32::EventLog</a>, requires a numeric EventId and a set of parameters joined by the NUL character. Win32 combines these with a DLL provided by the application writer to produce the final localised message seen by the user in the event viewer. Unix on the other hand via syslog, requires a string which is sent to the appropriate log file. This presents a big problem when trying to create a common logging API.</p><p>So far, the usual way of combining the two seems to be by in the background, providing an EventId of 0 (or whatever number) and a single parameter consisting of the entire message. This allows this sort of interface:</p><p> Log-&gt;send($the_entire_log_message) </p><p>However, the EventId is the only thing visible in the event viewer until you double click on the specific event to see more details about it. Therefore scrolling through X completely different entries all with an EventId of 0 is a bit tedious to say the least. So this sort of interface is familiar to the Unix programmers, but possibly a little misleading if they think their work will ever run seamlessly on windows.</p><p>My best effort at creating a combined win32 / unix log library has been to provide a call like this:</p><p> Log-&gt;new($numericId, \@parameters)-&gt;send(); </p><p>Which on unix opens the correct localisation file, creates the log message and sends it to syslog/wherever and on win32 sends direct to the event logger</p><p>Comments on these ideas?</p> ddick 2008-08-29T23:59:19+00:00 journal Melbourne.PM Win32 talk http://use.perl.org/~ddick/journal/36882?from=rss <p>I gave <a href="http://perl.net.au/wiki/Melbourne_Perl_Mongers/Meeting_History_2008_07">a talk</a> on things to think about to make a Win32 port easier at Melbourne.PM last night.</p><p>Although, as pointed out at the end of the night, it was actually more of a talk on making a perl program behave like a native Win32 program from the POV of an external customer.</p><p>Points covered were</p><ul> <li>correct Win32 File system layout</li><li>Logging (Win32::EventLog)</li><li>Services (Win32::Daemon)</li><li>Process Creation (Win32::Process)</li><li>Process Monitoring (Win32::Process::Info)</li><li>File System Security (Win32::FileSecurity)</li><li>short wix section</li></ul><p>All up, about an hour's worth of talk, after which i had to go instead of pubbing due to a nasty cold.</p> ddick 2008-07-09T23:34:27+00:00 journal my bad on the conf.d directories http://use.perl.org/~ddick/journal/36694?from=rss <p>Actually, having spent a bit more time with nginx and lighttpd, i confess that the <a href="http://use.perl.org/~ddick/journal/36152">previous accusations</a> of being unable to support conf.d was unfair. Both were able to do it, but for various reasons only lighttpd on debian was actually supported (out of the four combinations that i'm tracking, lighttpd/nginx on fedora/debian). Appropriate bugs were raised with maintainers and upstream and now nginx is supporting conf.d on fedora 9 and in debian sid. </p><p>very cool and much thanks to the excellent people maintaining the nginx distributions at debian and fedora and to the good upstream support from <a href="http://sysoev.ru/en/">Igor Sysoev</a>.</p><p>i still need <a href="http://trac.lighttpd.net/trac/ticket/1639">this bug</a> solved for my application to run under on lighttpd</p> ddick 2008-06-16T06:15:27+00:00 journal the close test http://use.perl.org/~ddick/journal/36471?from=rss <p>i seem to be evaluating a few new software packages, mostly web servers and web applications. i'm trying to think up heuristics to help me form a quick opinion of a new code base, mainly the probability that it will contain disastrous (requiring repeated and probably unsuccessfull (win32 shatter attacks) patching) flaws. one that i came up with was</p><p> <code>grep -r close * | less</code> </p><p>and check if the developers cared enough to actually check the return codes of system calls. i figured close is a good C &amp;&amp; Perl compatible call to search for.</p><p>nginx seems to at least make a determined effort, i'm starting to like this web server a lot. lighttpd of course, didn't make an attempt that i could see. so, on went the test. the next five fairly major projects (non-CPAN) i tested failed impressively as well. bad/meaningless test maybe?</p> ddick 2008-05-20T00:13:21+00:00 journal Big uptimes &amp; Melbourne PM http://use.perl.org/~ddick/journal/36435?from=rss <p>sadly enough, for linux and win32, i think all it means is that the system is broadcasting the fact that the responsible administrator is not applying security patches.</p><p>Linux at least seems to require a reboot for a new kernel rather a lot, like at least every couple of months.</p><p>On the bright side, $work is hosting the Melbourne Perl Monger meetings for an indefinite period, which is nice.</p><p>We had a meeting on Wednesday where we had a talk on git and lightning talks on fastcgi and port knocking. Followed up with beers across the road.</p> ddick 2008-05-16T00:16:08+00:00 journal web server interfaces and the importance of conf.d http://use.perl.org/~ddick/journal/36152?from=rss <p>I've been porting my perl web application to as many web servers as possible, trying for cgi or better where better is defined as stable (for well written code) and faster. This has meant fooling around with external fastcgi applications (i have approx 30 stub cgi programs, which tends to exclude the web server controlling fastcgi and also exclude scgi). It's also meant finding another web server (nginx) that apparently has it's <a href="http://wiki.codemongers.com/NginxEmbeddedPerlModule">own highly experimental version of mod_perl</a>.</p><p>So far, successfully ported to nginx (fastcgi), lighttpd (fastcgi), iis (isapi), apache (fastcgi &amp;&amp; mod_perl) and apache2 (mod_perl2).</p><p>Even though my application is therefore successfully tested on at least these web servers, i can only write packages (msi/rpm/dpkg) for iis and apache(?:2)?. All the others refuse to acknowledge the idea that a writer of a web-application requires a conf.d style directory to place their web server configuration snippet into. And some of these "snippets" can get quite large.</p><p>i think it's interesting that, apart from main players, i haven't been able to find a web server whose developers sat down and thought "how are our clients actually going to interact with our program"<nobr> <wbr></nobr>:)</p> ddick 2008-04-14T23:55:22+00:00 journal Security Issue or Not? http://use.perl.org/~ddick/journal/35913?from=rss <p>I've been experimenting with sending sms. </p><p>One of the available programs for this is smstools. Smstools requires the sender of the sms to write to a directory that the sms daemon monitors.</p><p>However, Fedora requires root permissions to write to that directory. Debian requires that you are the smsd user (who is a member of the dialout group). Neither system gives write privileges to a group.</p><p>Now, from the point of view of a user interacting with these packages, both provide the annoying problem that a set-uid binary is required, simply to send an sms.</p><p>However, i think this is also a security hole as well. Not in the actual package, but in that to use the package, a normal user must go through a privilege escalation process. Every system that wants to send an sms has to therefore write their own custom set-uid script/binary, causing the un-necessary potential for set-uid bugs/system takeover.</p><p>The Debian package of course only has the potential to elevate to smsd, but since smsd has the potential to send unlimited sms and erase all trace of it, the horror is still pretty real.</p><p>Does a security bug against these packages seem justified?</p> ddick 2008-03-16T06:51:23+00:00 journal perl core 5.8 fork test fails due to rand??? http://use.perl.org/~ddick/journal/35710?from=rss <p>I have to admit i found this quite frustrating.</p><p>I've written a set of programs that do nightly builds that feed into nightly tests, blah, blah.</p><p>One of the requirements is that we bundle our own version of perl with the software, so, every night, perl gets<nobr> <wbr></nobr>./Configure &amp;&amp; make &amp;&amp; make test &amp;&amp; make install.</p><p>After time, perl's make test failed in 't/op/fork.t'. The next night it worked thou.</p><p>After receiving a query about the unexpected build failure from the local sys. admin. team, i did a bad thing and decided that if fork was failing and then started working again, this could indicate a hardware issue.</p><p>*BBBBBBBBBBZZZZZZZZZZZZZZZTTTT*</p><p>Sorry!!! it could also indicate that 't/op/fork.t' is actually testing the rand() functionality.</p><p>'t/op/fork.t' doesn't do anything at all with srand before forking a calling rand in each new process.</p><p>The test depends on the rand() in each process producing different results</p><p>Not surprisingly, 't/op/fork.t' fails fairly regularly.</p> ddick 2008-02-21T00:22:02+00:00 journal use of perl considered dangerous? http://use.perl.org/~ddick/journal/35595?from=rss While playing with rpmlint on the rpms i build for $WORK, i was confronted with the following warning message for fedora, <br> <br>"dangerous-command-in-%pre perl"<br> <br> a quick check of the responsible script showed that perl was put in the same list as rm,ln,userdel,etc. python of course, was not considered dangerous. <br> <br>*sigh*<br> <br> there is a distinct possibility that my sense of humour is seriously lacking. more sleep required, and in the meantime, an addition to the custom rpmlint configuration file. ddick 2008-02-06T22:46:37+00:00 journal rpmlint? excellent. http://use.perl.org/~ddick/journal/35578?from=rss i've been a big fan of debian's lintian project for a while now because when a distribution/operating system goes to the effort of defining "best practice" for building packages, it makes it so much easier for the small software shops to package software that integrates easily with the host. i've only just discovered rpmlint, apparently fufilling the same role for rpm based distributions. anyone know of other operating systems/distribution with a similiar mechanism for detecting the "correctness" of an external software package? ddick 2008-02-05T00:34:23+00:00 journal where to go for perl with CVE-2007-5116 patch? http://use.perl.org/~ddick/journal/34990?from=rss I can't figure out how to get a source version of perl with recent security fixes applied to it, or even get a patch to apply to 5.8.8 or similiar. What am i missing? ddick 2007-11-27T22:45:59+00:00 journal POSIX::close vs close, Expect &amp;&amp; Proc::Daemon http://use.perl.org/~ddick/journal/34944?from=rss Proc::Daemon uses POSIX::close() to close all the existing file descriptors during the daemonising process. However, this seemingly causes a very subtle issue with Expect. If i call <br> <code> close(STDIN); close(STDOUT); close(STDERR); Proc::Daemon::Init(); </code> <br> then i can use Expect with no problems. However, just calling <br> <code>Proc::Daemon::Init();</code> <br> causes Expect to lose track of it's child processes/file handles. Very odd. ddick 2007-11-21T04:20:23+00:00 journal Amusing x/platform coding issues http://use.perl.org/~ddick/journal/34728?from=rss coding on the cygwin platform today, i was impressed by the utter absence, both from the main perl package or in any perl library package of the relatively minor 'Win32' module. However, impressive miss that this is, i don't think this beats the<nobr> <wbr></nobr>/usr/bin/perl from hpux 11 where 'Config.pm' was considered unworthy of inclusion. Sometimes, i get the thought that people consider cross platform perl code too easy by default, and they try to increase the challenges. Maybe. ddick 2007-10-22T06:34:39+00:00 journal World's first religious TOCTOU issue? http://use.perl.org/~ddick/journal/34651?from=rss All sort of <a href="http://edition.cnn.com/2007/TECH/space/10/10/russia.space.ap/?iref=mpstoryview">odd race conditions</a> can spring up if you speed things up enough... What started out as east might not remain so for very long... very similar resolution to a more traditional TOCTOU issue, only one measurement of east is taken, and that is at the start of the prayer. ddick 2007-10-11T05:02:09+00:00 journal new use.perl.org js. konq says ouch! http://use.perl.org/~ddick/journal/34611?from=rss viewing a journal and descending into the comments has become a pretty horrible experience at least using the default konqueror on suse 10.0 (konq 3.4.2 (Using KDE 3.4.2 Level "b" SUSE 10.0)). Journal pages with comments often completely refresh when you descend through the comments and sometimes lose track of which comment you are viewing. Just thought i would mention it. ddick 2007-10-05T01:35:43+00:00 journal lots of cpan testers http://use.perl.org/~ddick/journal/34165?from=rss <p>something seems to have happened recently to bring out lots of cpan testers. I recently fixed up Date::Holidays::AU, which then got 39 passes from cpan testers, about 4 times more than the previous version.</p><p>Looking at other minor modules, quite a lot of them seem to be receiving good numbers of testers too.</p><p> very cool and much appreciated.</p> ddick 2007-08-21T06:18:19+00:00 journal x/platform mac address retrieval? http://use.perl.org/~ddick/journal/33886?from=rss How to get a mac address from linux/solaris/aix/hpux/MSWin32? don't think this would be useful enough to send to cpan.org... but for future reference... <blockquote><div><p><small> <tt>#!<nobr> <wbr></nobr>/usr/bin/perl -w<br> <br>use strict;<br>use FileHandle();<br> <br>MAIN: {<br>&nbsp; my ($macAddress);<br>&nbsp; if (($^O eq 'linux') || ($^O eq 'solaris') || ($^O eq 'hpux') || ($^O eq 'aix')) {<br> <br>&nbsp; &nbsp; $ENV{PATH} = '/sbin:/usr/sbin:/bin:/usr/bin';<br>&nbsp; &nbsp; delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};<br> <br>&nbsp; &nbsp; my ($ifconfig) = new FileHandle();<br>&nbsp; &nbsp; if (my $pid = $ifconfig-&gt;open('-|')) {<br>&nbsp; &nbsp; &nbsp; my ($buffer);<br>&nbsp; &nbsp; &nbsp; unless (defined $ifconfig-&gt;read($buffer, 8192)) {<br>&nbsp; &nbsp; &nbsp; &nbsp; die("Failed to read from ifconfig:$!");<br>&nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; if (($^O eq 'linux') || ($^O eq 'solaris')) {<br>&nbsp; &nbsp; &nbsp; &nbsp; # linux preceeded by HWaddr, solaris by ether<br>&nbsp; &nbsp; &nbsp; &nbsp; if ($buffer =~<nobr> <wbr></nobr>/(?:HWaddr +|ether +)([0-9A-Fa-f]{1,2}):([0-9A-Fa-f]{1,2}):([0-9A-Fa-f]{1,2}):([0-9A-Fa-f]{1,2}):(<nobr>[<wbr></nobr> 0-9A-Fa-f]{1,2}):([0-9A-Fa-f]{1,2})/) {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $macAddress = formatMac($1, $2, $3, $4, $5, $6);<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; } elsif ($^O eq 'hpux') {<br>&nbsp; &nbsp; &nbsp; &nbsp; if ($buffer =~<nobr> <wbr></nobr>/^0x([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f<nobr>]<wbr></nobr> {2})([0-9A-Fa-f]{2}) +$/) {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $macAddress = formatMac($1, $2, $3, $4, $5, $6);<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; } elsif ($^O eq 'aix') {<br>&nbsp; &nbsp; &nbsp; &nbsp; if ($buffer =~ / +([0-9A-Fa-f]{1,2})\.([0-9A-Fa-f]{1,2})\.([0-9A-Fa-f]{1,2})\.([0-9A-Fa-f]{1,2})<nobr>\<wbr></nobr> <nobr> <wbr></nobr>.([0-9A-Fa-f]{1,2})\.([0-9A-Fa-f]{1,2}) +/) {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $macAddress = formatMac($1, $2, $3, $4, $5, $6);<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; unless ($ifconfig-&gt;close()) {<br>&nbsp; &nbsp; &nbsp; &nbsp; if (($^O eq 'linux') || ($^O eq 'solaris')) {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; die("Failed to successfully execute 'ifconfig -a':$!");<br>&nbsp; &nbsp; &nbsp; &nbsp; } elsif ($^O eq 'hpux') {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; die("Failed to successfully execute 'lanscan -a':$!");<br>&nbsp; &nbsp; &nbsp; &nbsp; } elsif ($^O eq 'aix') {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; die("Failed to successfully execute 'netstat -ia':$!");<br>&nbsp; &nbsp; &nbsp; &nbsp; } else {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; die("Unknown failure when determining mac address for '$^O'");<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; } elsif (defined $pid) {<br>&nbsp; &nbsp; &nbsp; eval {<br>&nbsp; &nbsp; &nbsp; &nbsp; if (($^O eq 'linux') || ($^O eq 'solaris')) {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; unless (exec({ 'ifconfig' } 'ifconfig', '-a')) {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; die("Failed to execute 'ifconfig -a':$!");<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp; } elsif ($^O eq 'hpux') {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; unless (exec({ 'lanscan' } 'lanscan', '-a')) {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; die("Failed to execute 'lanscan -a':$!");<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp; } elsif ($^O eq 'aix') {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; unless (exec({ 'netstat' } 'netstat', '-ia')) {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; die("Failed to execute 'netstat -ia':$!");<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp; } else {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; die("Failed to find a command to produce the mac address for '$^O'");<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; };<br>&nbsp; &nbsp; &nbsp; print STDERR $@;<br>&nbsp; &nbsp; &nbsp; exit(1);<br>&nbsp; &nbsp; } else {<br>&nbsp; &nbsp; &nbsp; die("Failed to fork:$!");<br>&nbsp; &nbsp; }<br>&nbsp; } elsif ($^O eq 'MSWin32') {<br>&nbsp; &nbsp; my ($ipconfig) = new FileHandle("ipconfig<nobr> <wbr></nobr>/all |");<br>&nbsp; &nbsp; unless ($ipconfig) {<br>&nbsp; &nbsp; &nbsp; die("Failed to 'ipconfig<nobr> <wbr></nobr>/all':$!");<br>&nbsp; &nbsp; }<br>&nbsp; &nbsp; my ($buffer);<br>&nbsp; &nbsp; unless (defined $ipconfig-&gt;read($buffer, 8192)) {<br>&nbsp; &nbsp; &nbsp; die("Failed to read from ipconfig:$!");<br>&nbsp; &nbsp; }<br>&nbsp; &nbsp; if ($buffer =~<nobr> <wbr></nobr>/^ +Physical Address(?:\. )+: ([0-9A-Fa-f]{1,2})\-([0-9A-Fa-f]{1,2})\-([0-9A-Fa-f]{1,2})\-([0-9A-Fa-f]{1,2})\<nobr>-<wbr></nobr> ([0-9A-Fa-f]{1,2})\-([0-9A-Fa-f]{1,2})/m) {<br>&nbsp; &nbsp; &nbsp; $macAddress = formatMac($1, $2, $3, $4, $5, $6);<br>&nbsp; &nbsp; }<br>&nbsp; &nbsp; unless ($ipconfig-&gt;close()) {<br>&nbsp; &nbsp; &nbsp; die("Failed to close 'ipconfig<nobr> <wbr></nobr>/all':$!");<br>&nbsp; &nbsp; }<br>&nbsp; } else {<br>&nbsp; &nbsp; die("'$^O' cannot be recognised");<br>&nbsp; }<br>&nbsp; print "mac address is $macAddress\n";<br>}<br> <br>sub formatMac {<br>&nbsp; my (@octets) = @_;<br>&nbsp; return join(':', map { sprintf('%.2X', hex($_)) } @_);<br>}</tt></small></p></div> </blockquote> ddick 2007-07-26T06:28:02+00:00 journal Australia's character test http://use.perl.org/~ddick/journal/33814?from=rss <p>The saga over Dr Haneef just gets dumber and dumber. I'm trying hard to believe that our country has an effective and efficient police force, but with the curse of the internet and the ready access to information, this state of mind becomes harder and harder to maintain. According to <a href="http://www.smh.com.au/news/national/haneefs-detained-after-bail-win/2007/07/16/1184438190629.html">local papers</a> Dr Haneef, who has been released on bail due to the exceptional weak case the AFP have constructed, has now been detained in an immigration detention centre. Our federal Immigration minister, Kevin Andrews has decided that despite the release on bail, and that whole daft presumption of innocence thingy, Dr Haneef has failed the "character" test. The only possible conclusion i can come to is that he is implying that Dr Haneef is actually innocent and therefore unfit to be living in a land mostly populated by ex-convicts.</p> ddick 2007-07-16T04:34:41+00:00 journal