title: Do we have an autochomp in Perl?
body: <p>This is what my Perl code looks like for <a href="https://stackoverflow.com/questions/3691739/a-program-to-monitor-a-directory-on-linux/3691799#3691799">monitoring a Unix folder</a> :</p>
  
  <pre><code>#!/usr/bin/perl
  use strict;
  use warnings;
  use File::Spec::Functions;
  
  my $date    = `date`; chomp $date;
  my $datef   = `date +%Y%m%d%H%M.%S`; chomp $datef;
  my $pwd     = `pwd`; chomp $pwd;
  
  my $cache   = catfile($pwd, "cache");
  my $monitor = catfile($pwd, "monme");
  my $subject = '...';
  my $msg     = "...";
  my $sendto  = '...';
  my $owner   = '...';
  
  sub touchandmail {
       `touch $cache -t "$datef"`;
       `echo "$msg" | mail -s "$subject" $owner -c $sendto`;
  }
  
  while(1) {
  
      $date  = `date`; chomp $date;
      $datef = `date +%Y%m%d%H%M.%S`; chomp $datef; 
  
      if (! -e "$cache") {
          touchandmail();
      } elsif ("`find $monitor -newer $cache`" ne "") {
          touchandmail();
      }
      sleep 300;
  }
  </code></pre>
  
  <ul>
  <li><p>To do a <code>chomp</code> after every assignment does not look good. Is there some way to do an "autochomp"?</p></li>
  <li><p>I am new to Perl and might not have written this code in the best way. Any suggestions for improving the code are welcome.</p></li>
  </ul>