<?xml version="1.0" encoding="windows-1252"?>
<node id="989363" title="Re^2: if,if and again,if" created="2012-08-23 13:57:19" updated="2012-08-23 13:57:19">
<type id="11">
note</type>
<author id="421114">
Tanktalus</author>
<data>
<field name="doctext">
&lt;p&gt;Data-driven approaches FTW!&lt;/p&gt;
&lt;p&gt;Though I'd be tempted to do things a bit more perlishly (at least for my own definition of perlish):
&lt;c&gt;
my @matchers = (
  [ qr/(Lz0|PLATO)/i =&gt; 'Apps' ],
  ...
);
for my $check (@matchers) {
  if ($release_name =~ $check-&gt;[0]) {
    $category = $check-&gt;[1];
    print "[INFO] Category: $category\n";
    last;
  }
}
&lt;/c&gt;
Actually, a bit more perlish, IMO, would be to replace that for loop altogether:
&lt;c&gt;
use List::Util qw(first);
my $category = map {
  $_ ? $_-&gt;[1] : undef;
} first {
  $release_name =~ $_-&gt;[0];
} @matchers;
if ($category)
{
  print "[INFO] Category: $category\n";
}
else
{
  print "[ERROR] Unrecognised release type: $release_name\n";
}
&lt;/c&gt;
But maybe that's just me. :-)&lt;/p&gt;</field>
<field name="root_node">
988660</field>
<field name="parent_node">
988676</field>
</data>
</node>
