title: tsung_stats.pl on Mac OS X Mavericks run into "Can't locate Template.pm" error
body: <p>I'm trying to run tsung_stats.pl from tsung (installed through brew) on Mac OS X 10.9 and got error:</p>
  
  <blockquote>
    <p>Can't locate Template.pm in @INC (@INC contains:
    /Library/Perl/5.16/darwin-thread-multi-2level /Library/Perl/5.16
    /Network/Library/Perl/5.16/darwin-thread-multi-2level
    /Network/Library/Perl/5.16 /Library/Perl/Updates/5.16.2
    /System/Library/Perl/5.16/darwin-thread-multi-2level
    /System/Library/Perl/5.16
    /System/Library/Perl/Extras/5.16/darwin-thread-multi-2level
    /System/Library/Perl/Extras/5.16 .) at tsung_stats.pl line 564</p>
  </blockquote>
  
  <p>I searched and it seems I have to install perl templates, so I ran "sudo cpan Template" and yet still get the same error.</p>
  
  <p>cpan and perl are all in /usr/bin/. Tsung is in /usr/local/Cellar/tsung/1.5.0/bin/tsung</p>
  
  <p>Versions are:
  perl: perl 5, version 16, subversion 2 (v5.16.2)
  cpan: 1.57
  tsung: 1.5.0</p>
  
  <p>I searched my system and found no file name Template.pm. The closest I found was two TextTemplate.pm files in </p>
  
  <pre><code>/System/Library/Perl/Extras/5.16/Locale/Maketext/Extract/Plugin/
  /System/Library/Perl/Extras/5.12/Locale/Maketext/Extract/Plugin/
  </code></pre>
  
  <p>The following code snippet in question starts from line 563:</p>
  
  <pre><code>sub html_report {
      require Template;
      my $titre     = 'Tsung ';
      my $version   = $tagvsn;
      my $contact   = 'tsung-users@process-one.net';
      my $output   = 'index.html';
  
      my $tt = Template-&gt;new({
                              INCLUDE_PATH =&gt; $template_dir,
                              PRE_CHOMP    =&gt; 1,
                              INTERPOLATE  =&gt; 1,
                             }) or die "Template error " . Template-&gt;error();
      my $xml_conf;
      opendir (DIR, ".") or warn "can't open directory .";
      while (my $file = readdir (DIR) ) {
          if ($file =~ /.xml$/) {
              $xml_conf= $file;
          }
      }
      foreach my $type ("mean", "maxmean", "minmean") {
          foreach my $data (keys % {$maxval-&gt;{$type}} ) {
              next if ($data =~ m/^size/);
              if ($data =~ m/os_mon/) {
                  $maxval-&gt;{$type}-&gt;{$data} = sprintf "%.2f",$maxval-&gt;{$type}-&gt;{$data};
                  next;
              }
              next if not ($data eq "session" or $data eq "connect" or $data eq "request" or $data eq "page" or $data =~ m/^tr_/);
              $maxval-&gt;{$type}-&gt;{$data} = &amp;formattime($maxval-&gt;{$type}-&gt;{$data});
          }
      }
      foreach my $size ("size_rcv", "size_sent") {
          if ($maxval-&gt;{rate}-&gt;{$size}) {
              $maxval-&gt;{rate}-&gt;{$size} = &amp;formatsize($maxval-&gt;{rate}-&gt;{$size}*8,"bits");
              $maxval-&gt;{maxmean}-&gt;{$size} = &amp;formatsize($maxval-&gt;{maxmean}-&gt;{$size},"B");
          } else {
              warn "$size is equal to 0 !\n";
          }
      }
  
      my $vars =
          {
           version     =&gt; $version,
           os_mon      =&gt; $extra,
           errors      =&gt; $errors,
           title       =&gt; $titre,
           subtitle    =&gt; "Stats Report",
           http        =&gt; $http,
           stats_subtitle =&gt; "Stats Report ",
           graph_subtitle =&gt; "Graphs Report ",
           contact     =&gt; $contact,
           data        =&gt; $maxval,
           cat_data    =&gt; $category,
           conf        =&gt; $xml_conf
          };
      $tt-&gt;process("report.thtml", $vars, "report.html") or die $tt-&gt;error(), "\n";
      $vars =
          {
           version     =&gt; $version,
           os_mon      =&gt; $extra,
           errors      =&gt; $errors,
           http        =&gt; $http,
           match       =&gt; $match,
           async       =&gt; $async,
           bosh       =&gt; $bosh,
           title       =&gt; $titre,
           subtitle    =&gt; "Graphs Report",
           stats_subtitle =&gt; "Stats Report ",
           graph_subtitle =&gt; "Graphs Report ",
           os_mon_other=&gt; $os_mon_other,
           contact     =&gt; $contact,
           conf        =&gt; $xml_conf,
           ext         =&gt; $imgfmt
          };
    if (not $dygraph) {
      $tt-&gt;process("graph.thtml", $vars, "graph.html") or die $tt-&gt;error(), "\n";
    } else {
      $tt-&gt;process("graph_dy.thtml", $vars, "graph.html") or die $tt-&gt;error(), "\n";
      copy (($template_dir . "/dygraph-combined.js"), ".") or die "copy failed : $!";
    }
  }
  </code></pre>
  
  <p>I believe $template_dir is in this piece of code (start from line 71):</p>
  
  <pre><code>my $prefix ="/usr/local/Cellar/tsung/1.5.0";
  
  unless ($template_dir) {
      if (-d (dirname($0) . "/templates/")) {
          $template_dir = dirname($0)."/templates/";
      } elsif (-d "$ENV{HOME}/.tsung/templates/") {
          $template_dir = "$ENV{HOME}/.tsung/templates/";
      } elsif (-d "${prefix}/share/tsung/templates") {
          $template_dir = "${prefix}/share/tsung/templates";
      } elsif (-d "/usr/share/tsung/templates") {
          $template_dir = "/usr/share/tsung/templates";
      } elsif (-d "/usr/local/share/tsung/templates") {
          $template_dir = "/usr/local/share/tsung/templates";
      } else {
          warn "Can't find template directory !";
      }
  }
  </code></pre>
  
  <p>I checked those locations and found some .pm files, but none were Template.pm.</p>
  
  <p>Any help would be appreciated.</p>