title: How do I format dates in Perl?
body: <p>I'm modifying a pre-existing script in Xcode to customize my file headers. The script is Perl and it's not my best langage. :)</p>
  
  <p>I just need to insert the current date in the header in dd/mm/yy format.</p>
  
  <p>Here is my script :</p>
  
  <pre><code>#! /usr/bin/perl -w
  # Insert HeaderDoc comment for a header
  #
  # Inserts a template HeaderDoc comment for the header.
  use strict;
  
  # get path to document
  my $headerPath = &lt;&lt;'HEADERPATH';
  %%%{PBXFilePath}%%%
  HEADERPATH
  chomp $headerPath;
  my $rootFileName = &amp;rootFileNameFromPath($headerPath);
  
  print "/*";
  print " * $rootFileName\n";
  print " * Project\n";
  print " *\n";
  print " * Created by Me on ";
  # in bash it would be something like that :
  # date +%d/%m/%y | awk '{printf "%s\n", $1}';
  print " * Copyright 2009 My_companie. All rights reserved.\n";
  print " *\n";
  print " */\n";
  
  sub rootFileNameFromPath {
      my $path = shift;
  
      my @pathParts = split (m'/', $path);
      my $filename = pop (@pathParts);
      my $rootFileName = "$filename";
      $rootFileName =~ s/\.h$//;
      return $rootFileName;
  }
  
  exit 0;
  </code></pre>
  
  <p>I've just modified the print command so don't ask me for the rest of the code :)</p>