title: Automation in Perl script
body: <p>I am running a perl script. In my perl script, I check the current date and the folder name(which is also in the date format like for example 11-12-07). This perl script run automatically when It checks the curent date with the folder name. The folder is a tar folder which is loaded from other server. </p>
  
  <p>So, basically I need to run the script if it matched with the folder name and current date. </p>
  
  <p>Problem: Sometimes, I used to get the folder next day and my perl script checks only for the current date. The folder i get has the name which is previous date (not the current date).So, I need to do processing of the folder manually. I need to automate it in my perl script. </p>
  
  <p>Please suggest me some ideas to make it happen.</p>
  
  <p>Thanks!!</p>
  
  <p>Code for Reference:</p>
  
  <pre><code>my $tfilename = 'tarmd5.tar';
  my $td = `date '+%y-%m-%d'`;    # date in yy-mm-dd format
  chomp ($td);
  my $td2 = `date '+%Y%m%d'`;     # date in yyyymmdd format
  chomp ($td2);
  
  
  #
  # get directory from command line
  $dir = shift;
  leave("'$dir' is not a valid directory") unless (-d $dir);
  if    ($dir eq '.') {$dir = cwd();}
  elsif ($dir !~ /^\//) {$dir = cwd()."/$dir";}
  
  
  # print out the time
  print scalar(localtime()),"\n";
  
  
  ######## This section unpacks transferred data ########
  # go to directory for today and find *tar.gz files to copy
  
  my $dday = "$dir/$td";
  next unless (-d "$dday");
  @gzfiles = glob("$dday/*tar.gz");
  foreach $zf(@gzfiles) {
    next if (($zf =~ /BMP/) || ($zf =~ /LG/) || ($zf =~ /MAP/) || ($zf =~ /STR/));
    print "$zf\n";
    ($status,$message) = systemcall("/bin/cp $zf $fdir");
  }
  </code></pre>