Here's the complete text of the entry you were just reading. To return to the whole blog, click the Blogolalia button at left.

August 31, 2003  

Writer's blok

Flew solo today...20 lines or so, without having to check the book. LOL! Got a suggestion from the Blosxom plugins page to add Windows line-end conversion to blox; just one line. But that presented a small quandary...the Pascal Protestant in me worried about crossing a line between attaining Perl's laziness and rewarding damnable ignorance. (On the Mac at least, Pascal's pearly gates bear a sign: "You must be able to generate at least this much machine language to ride this code." ;-)

And I mean, Great Bog...knowing about formatting text with newlines is as fundamental as knowing which side of the road to drive on. One of those underlying pieces of infrastructure that defines the world of multi-platform diversity. Isn't it? Or is there a new day coming when anyone can be (and should be) be a user, and lusers will only exist due to bad design or poor documentation? Does every specific convenience carry with it this cost of obscuring broader knowledge? Which is it -- can of worms, or slippery slope?


But then I perceived an actual need -- fixing input from Macs or Wintels via plugins such as writeback. So, no more quandary; time for coding. It didn't seem fair to translate Win line-ends without doing Macs, so I looked into pulling $story out of $title's ass (as it were) when entry text uses returns as line-ends. Took about 30 minutes to outline and implement:

if ($$title_ref =~ m/\r/) {
  $$title_ref =~ s/\r/\n/;
  my $temp;
  ($$title_ref,$temp) = split /\n/, $$title_ref, 2;
  $$body_ref = $temp . $$body_ref;
}
if ($$body_ref =~ m/\r/) {
  $$body_ref =~ s/^\r\n/\n\n/ or $$body_ref =~ s/^\r/\n\n/;
  $$body_ref =~ s/\r\n/\n/gm;
  $$body_ref =~ s/\r/\n/gm;
}

So that was kinda nice; getting my toe wet "thinking in Perl," and doing some meta-thinking about Perl. And, of course, being able to write lines without having to crack the book ;-) The new code has been added to blox, and also put out into a separate plugin, blok. (I even figured out how to workaround <pre> tags[!] -- but it uses a loop, and I'd like to do it all with straight substitution, so no go for now....)

Well then, flush with contentment, I wanted to try some index pages and play with "breadcrumb" trails. Put together my own little routine for extracting path items, then downloaded Rael's breadcrumbs plugin to compare. Rael's method is (of course ;-) more efficient than mine, but hey -- mine worked! Then I played with the breadcrumbs plugin, but I didn't really like it running from the head sub.... So I put some new skin on it and named it crumz. The link trail in crumz is generated in the story() sub, so path names are complete; options include path-with-file-name or directories-only, and trimming leading path items.

And then, I fixed a couple of YAHAs with seemore and sort_order.

Book time: zero

Woo-hoo! My first foray into Perl without needing the book. Simple stuff, to be sure, but I didn't step on my weenie once (at least, not with the Perl ;-) Woo-hoo!