some guy on the Internet

the network engineer fears the backhoe, and the systems engineer fears the network engineer

An Entirely Needless Obstruction

| Comments

OK, see this? This is why people say uncharitable things about Perl:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
for (@cmd)
{
    next unless grep /^\Q$cmd\E$/, split(" ", $_->[1]);
    $cmd_data = $_;
    push @{$cmd_data->[3]}, ["filter", undef, undef, \&parse_filter] if $_->[1] =~ /\bdescribe/;
    for (@{$cmd_data->[3]})
    {
  for (split(" ", $_->[0]))
  {
      (my $key = $_) =~ s/-/_/g;
      $keyword{$key} = undef;
  }
    }
    last;
}

It doesn’t matter whose code this is. Suffice it to say that it

  • is a crucial part of a publically-available, fairly popular program,
  • was last edited in 2011,
  • is standing in the way of my getting something accomplished today.

Where to even start? What’s with the magical anonymous array-indexed data structures? The positional parameters (gotta pass those undefs or everything is busted)? The assignment of named variables to $_ (yay!) and then going on to dereference $_ instead of the named variables?

I’m not sure I’m willing to give this a pass as being baby Perl; this is just a design that has been stretched comically (tragically?) far beyond its original limits. This makes me cranky and sad.

Time to figure out what the hell is going on here so that I can patch this code. Fantastic.

Comments