Intermission on the livewire

Posted Mon 26 Nov
3 comments so far

Are you a stat whore? (And all webmasters are, although I don’t pay much attention to mine anymore. I used to, I just don’t these days.) Do you use awstats? Well, there is a prettification of that hoary old hacky script. I recommend it to all. Go get it.

jawstats. It rocks.

While we are talking of code (ish, as jawstats is all flash and trousers), consider this. It didn’t fox me, but it made me laugh.

  #!/usr/bin/perl -w
  use Test::More tests => 2;
  use constant FILE => 'my_file';
  is -e FILE => undef, FILE . 'does not exist';
  ... # do stuff that creates file
  is -e FILE => 1, FILE . ' now exists';

So I run my test script, and it fails. Oh gn0es! But I look at it, with a little help of my colour syntax highlighting, and it is obvious. snort I laughed. See, I use fat commas in an is, because it looks nice. Sort of makes a visual association, nothing more than that. Just one of those little idomaticnesses that I do. Another is I never use foreach. In fact, I hate seeing foreach in code. Just use for, people, it makes a lot more sense. (In case you are wondering why I was testing for file existence, well, I was fetching from an external secure FTP site. And to make sure I can get there, I nab the .bashrc, then make sure it is on the local drive. Yes, I know.)

Because no one is actually reading at this point, here is another snippet of code:

  #!/usr/bin/perl -w
  use Data::Dumper;
  use constant {
    FOO => 'invisible constant',
    BAR => [ 'do', 'not', 'want' ],
    BAZ => 'heylo',

  my $one = join ' ', BAR;
  my $two = join ' ', (BAR);
  my $three = join ' ', map BAR->[$_],
    0 .. scalar @{ (BAR) } - 1;
  my $four = join ' ', @{ (BAR) };

  warn Dumper (BAR, $one, $two, $three, $four);

See what I did there? Ass. Bitten. Wasn’t. Thinking.

Java has returned to my life, so I am brushing up on that again. Been a long time, and I now remember how much of a pain it is. But there is reason.

Anyway, did I mention you should go get jawstats? Disclaimer: I have nothing to do with it.

  1. Nice shoes

    Mon 26 Nov, 10:51AM

  2. I’m with that crazy ozzie professor on this one. Say no to use constants. Just use a capital $THINGY and be done with it.

    If you really really care that it’s not modified you could use readonly. But I think we all agree we really can’t be arsed with that.

    Mark Fowler
    Mon 26 Nov, 12:15PM

  3. Nelly: thanks.

    Mark: I actually like ‘use constant’. It seems a lot nicer than a my ($ONE, $TWO, $THREE) = (1, 2, 3); in a script. I dunno why, it just seems so to me. As for aforementioned Ozzie prof, I amn’t a big fan of PBP. And it isn’t so much the non-readonly-ness (no, none of use cba with that), it is just aesthetic.

    Stray Taoist
    Mon 26 Nov, 1:58PM

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

Leave the dark corners of the interweb alone. Go to the bright spots shone on by the Beautiful Ones

The BlackStar Diaspora

The wulf insists on text here...and I shall leave it at that.

People I know

I know people who didn't work at BlackStar, and they have weblogs too. These are they.

News, politics and paranoia

The State is not your friend


It is a well-known fact that the Stray Taoist (nee Toaster) isn't as internally consistent as he thinks he is. Welcome to his world.

Feeds: RSS | Atom