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. :)
I just need to insert the current date in the header in dd/mm/yy format.
Here is my script :
#! /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 = <<'HEADERPATH';
%%%{PBXFilePath}%%%
HEADERPATH
chomp $headerPath;
my $rootFileName = &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;
I've just modified the print command so don't ask me for the rest of the code :)