Happy Birthday to Me!

Bash (sneaky): 36

touch $0;echo Happy Birthday to me\!

According to the rules: "creation, modification or compilation time of the program". I choose modification time, and a perpetual self-modification. [HT @ace for 1 char]

Perl (also sneaky): 29

print "Happy birthday to me!"

This one is arguably less sneaky than the first; Perl programs are always compiled before they are executed, which not everyone knows - see, there is an educational spin on the sneakiness. So here it is the compilation date that I'm using.

-- Edit for rule change --

This was written before there was any rule about changing your birthday. I think the Perl one still stands; all Perl programs are compiled before they are run. I'll leave the answer here for educational reasons!


bash - 65

[ `date +%d%m -r $0` = `date +%d%m` ]&&echo Happy birthday to me!

Thanks to ugoren, ace and nyuszika7h for help.


PHP 77 75 74 65 60

Many thanks to the superb suggestions from Tim Seguine:

<?date(dm,getlastmod())-date(dm)&&die?>Happy birthday to me!

Sneaky PHP: 46 42 41 40

Using Phil H's idea and again Tim Seguine's suggestion:

<?touch(__FILE__)?>Happy birthday to me!

Tags:

Code Golf