stvn_skuo's Journal
http://use.perl.org/~stvn_skuo/journal/
stvn_skuo's use Perl Journalen-ususe 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:39:20+00:00pudgepudge@perl.orgTechnologyhourly11970-01-01T00:00+00:00stvn_skuo's Journalhttp://use.perl.org/images/topics/useperl.gif
http://use.perl.org/~stvn_skuo/journal/
Nevermind
http://use.perl.org/~stvn_skuo/journal/27302?from=rss
<br>
I think the xml files that were there
in <tt>blib</tt> came from my having
used <em>EUMM</em> earlier.<br> <br>
Note to self: Already run <tt>realclean</tt>
when switching from <em>ExtUtils::MakeMaker</em>
to <em>Module::Build</em>.stvn_skuo2005-10-25T04:58:58+00:00journalModule::Build weirdness
http://use.perl.org/~stvn_skuo/journal/27299?from=rss
<br>
I would have sworn that <em>Module::Build</em>
had been doing "the right thing" all along.<br> <br>
Given<blockquote><div><p> <tt>lib/Foo/foo.PL</tt></p></div> </blockquote><p>and</p><blockquote><div><p> <tt>PL_files => {<br> 'lib/Foo/foo.PL' => 'lib/Foo/foo.xml',<br>}</tt></p></div> </blockquote><p>
I saw it copy <tt>foo.xml</tt> into the
<tt>blib</tt> directory, etc.<br> <br>
I added one more item to PL_files,
re-ran <tt>Build.PL</tt>, re-ran my tests, and
all of a sudden the xml files were
no longer being copied into <tt>blib</tt>
thus causing tests to fail.<br> <br>
No worries as all was well again
after I added</p><blockquote><div><p> <tt>$builder->add_build_element('xml');</tt></p></div> </blockquote>stvn_skuo2005-10-24T20:54:17+00:00journalMREs -- now with steroids...
http://use.perl.org/~stvn_skuo/journal/26624?from=rss
<br> <br>
Years ago, after graduating from high school, I
considered joining the Marines as a means of
getting a college education.
I went to the recruiting office and took the "written test" and was scheduled to take a physical exam weeks later.
The timely arrival of a college acceptance letter
with an offer of a scholarship diverted me away from the military.<br> <br>
Thinking back, I doubt I would have made it through boot camp. I was fit and trim from having been on the swim team but I never did have the physique for any "real combat".<br> <br>
At the <em>Tomb of the Unknown Soldier</em> in Arlington National Cemetery, when I visited there on vacation, I saw The. Biggest. Guard. Ever.
He had a shaved head, crisp uniform, big stompy boots -- except that he barely made any sound as he patrolled back and forth -- and precise turns made while carrying a rifle.
Not the rat-tat-tat automatic weapon kind of rifle -- the kind with bolt-action that makes a satisfying click-click
sound (or so I imagine from seeing countless action movies, as I've never fired a gun).<br> <br>
What brought this to mind was seeing the funeral procession of William Rehnquist, the late Supreme Court Justice, on television this morning.
His pall bearers were his former clerks. I'm not saying all his clerks eventually found desk jobs where their daily routine now involve lifting
items no heavier than a briefcase -- I'll just say that they seem a bit strained while transporting the casket. Contrast that to the funeral of
Ronald Reagan, the 40th President, whose coffin was carried, seemingly effortlessly, by marching military guards.<br> <br>
Either the recruiters for the armed forces have a great screening process to pick out the biggest, strongest guys, or they're putting steroids into MREs (yup, steroids).stvn_skuo2005-09-07T04:33:53+00:00journalJust in time
http://use.perl.org/~stvn_skuo/journal/26114?from=rss
Thanks <a href="http://use.perl.org/~rafael/journal/26092">
rafael</a>.
I was just looking for a way to compare files as strings and found File::Compare a bit lacking.
<br>
<br>
Looks like someone else besides me would like an
option to ignore <a href="http://rt.cpan.org/NoAuth/Bug.html?id=14018">
differences in number of whitespaces</a>. Other options I
often use with the Unix <em>diff</em> utility include those to
<ul> <li> ignore
differences between lower- and upper-case letters, and </li><li>
expand tabs to whitespace.</li></ul><p>
I suppose I could preprocess the strings before handing
them off to <tt>is_string()</tt>:</p><blockquote><div><p> <tt>use Text::Tabs;<br>use Test::More tests => 1;<br>use Test::LongString;<br> <br># Apply one or more filters.<br># N.B. The order in which the filters are applied matters:<br> <br>my @strings =<br> map {tr/\n\r\f /<nobr> <wbr></nobr>/s; $_}<br> map expand($_) =><br> map lc($_) =><br> <DATA>;<br> <br>is_string(<br> $strings[0],<br> $strings[1],<br> 'Actually differs by one char'<br>);<br> <br>__DATA__<br>This is a test of Test::LongStrings<br>this is a test of Test::longstring</tt></p></div> </blockquote><p>
As far as the <tt>_common_prefix_length</tt>
function is concerned, perhaps using
<tt>substr</tt> would be a bit faster?</p><blockquote><div><p> <tt> while (length($x) && length($y)) {<br>- my ($x1,$x2) = $x =~<nobr> <wbr></nobr>/(.)(.*)/s;<br>- my ($y1,$y2) = $y =~<nobr> <wbr></nobr>/(.)(.*)/s;<br>+ my $x1 = substr($x, 0, 1, '');<br>+ my $y1 = substr($y, 0, 1, '');<br> if ($x1 eq $y1) {<br>- $x = $x2;<br>- $y = $y2;<br> ++$r;<br> }</tt></p></div> </blockquote>stvn_skuo2005-08-05T06:13:54+00:00journalSuperbowl Sunday
http://use.perl.org/~stvn_skuo/journal/23046?from=rss
I wonder how long it'll take
before the Patriots' logo appears
above the "use Perl;" banner...stvn_skuo2005-02-06T15:57:40+00:00journalslowly going through perlapi
http://use.perl.org/~stvn_skuo/journal/23032?from=rss
Notes to self:<ul>
<li>With Inline::C, arguments to variadic C functions should be processed with
<tt>Inline_Stack_Item(s)</tt>, instead of the functions declared in
<tt><stdarg.h></tt>.</li>
<li>Calling Perl subroutines from C? Better start reading
<i>perlguts</i>, <i>perlapi</i>, and <i>perlcall</i>.</li>
</ul><p>
I don't do any XS programming, but I do use C often enough
to think learning Inline to be worthwhile and, well, fun. After
my first experience with Inline, I really have to give kudos to those in<nobr> <wbr></nobr><tt>/p\d+p/</tt> who so deftly handle three disciplines (e.g, Perl, C,
and XS).</p><p>
My first naive attempt went something like this:</p><blockquote><div><p> <tt>use Inline 'C';<br> <br>my @integers = (4, 2, 1, 5, 6, 3);<br> <br>print +choose(\&lessthan, scalar @integers, @integers);<br>print +choose(\&grtrthan, scalar @integers, @integers);<br> <br>__DATA__<br>__C__<br> <br>#include <stdio.h><br>#include <stdlib.h><br>#include <stdarg.h><br> <br>int lessthan (int a, int b)<br>{<br> return (a < b) ? a : b;<br>}<br>int grtrthan (int a, int b)<br>{<br> return (a > b) ? a : b;<br>}<br>int choose( int(*fn)(), size_t count, int first,<nobr> <wbr></nobr>...)<br>{<br> va_list arg_ptr;<br> int next;<br> int keep;<br> va_start(arg_ptr,count);<br> keep = va_arg(arg_ptr, int);<br> for(--count; count > 0; --count) {<br> next = va_arg(arg_ptr, int);<br> keep = fn(keep, next);<br> }<br> return keep;<br>}</tt></p></div> </blockquote><p>In retrospect, other than as a learning exercise, this
wasn't an ideal test of Inline::C. There's no
speed advantage over a pure perl implementation. I
ended up with something that seems to be half C and half XS:</p><blockquote><div><p> <tt>use Inline 'C';<br>my @integers = (4, 2, 1, 5, 6, 3);<br> <br>local $\ = "\n";<br>print +choose(\&lessthan, @integers);<br>print +choose(\&grtrthan, @integers);<br> <br>__DATA__<br>__C__<br> <br>#include <stdio.h><br>#include <stdlib.h><br> <br>int lessthan (int a, int b)<br>{<br> return (a < b) ? a : b;<br>}<br>int grtrthan (int a, int b)<br>{<br> return (a > b) ? a : b;<br>}<br>int choose(CV *fn, int first,<nobr> <wbr></nobr>...)<br>{<br> SV *next_sv;<br> SV *keep_sv;<br> unsigned int count;<br> <br> Inline_Stack_Vars;<br> <br> keep_sv = newSVsv(Inline_Stack_Item(1));<br> for(count = 2; count < Inline_Stack_Items ; ++count)<br> {<br> I32 retval;<br> dSP;<br> ENTER;<br> SAVETMPS;<br> next_sv = newSVsv(Inline_Stack_Item(count));<br> PUSHMARK(SP);<br> XPUSHs(sv_2mortal(newSVsv(keep_sv)));<br> XPUSHs(sv_2mortal(next_sv));<br> PUTBACK;<br> retval = call_sv((SV *)fn, G_SCALAR);<br> SPAGAIN;<br> if (retval != 1)<br> {<br> croak("Big trouble\n");<br> }<br> sv_setsv(keep_sv, POPs);<br> FREETMPS;<br> LEAVE;<br> }<br> Inline_Stack_Reset;<br> Inline_Stack_Done;<br> return (int)SvIV(keep_sv);<br>}</tt></p></div> </blockquote>stvn_skuo2005-02-05T22:00:43+00:00journalHARNESS_PERL
http://use.perl.org/~stvn_skuo/journal/22921?from=rss
<blockquote><div><p> <tt>[sunnydale:~] skuo% prove -Iblib2/lib t/*.t<br> <br>t/00load.....Perl lib version (v5.8.6) doesn't match executable version (v5.8.0) at<nobr> <wbr></nobr>/usr/local/lib/perl5/5.8.6/darwin/Config.pm line 32.<br>Compilation failed in require at<nobr> <wbr></nobr>/usr/local/lib/perl5/5.8.6/Test/Builder.pm line 18.</tt></p></div> </blockquote><p>It's my fault for having two different versions of
perl: 5.8.6 under<nobr> <wbr></nobr>/usr/local/bin and Apple's default perl under<nobr> <wbr></nobr>/usr/bin.
</p><p>
It turns out that $^X is set to the string 'perl' and trips
up my effort at running tests. All's well after setting HARNESS_PERL in my environment to<nobr> <wbr></nobr>/usr/local/bin/perl.
</p><p>
Perhaps one of the %Config entries should replace $^X
inside Test::Harness::Straps (e.g., in &_command)?</p>stvn_skuo2005-01-28T07:02:44+00:00journal