On 31 Jan 02 at 05:17:17PM, Pradeep Sethi wrote: > Hi All, > > I want to change date 9/9/1987 to 09/09/1973
I assume the change in year was an accident. > was wondering, what is the most efficient way ? Well, this won't be the "most" efficient way, but it should be reasonably efficient, and will work with dates that include varying degrees of pre-existing zero-padding. #!/usr/bin/perl -w foreach $date (<DATA>) { chomp $date; print "$date: "; $date =~ s%^(\d)(?=/)%0$1%; $date =~ s%(?<=^\d\d/)(\d)(?=/)%0$1%; print "$date\n"; } __DATA__ 1/1/1999 03/04/2020 09/9/1987 9/09/1987 09/09/1987 12/12/2000 12/6/2000 6/12/2000 output: 1/1/1999: 01/01/1999 03/04/2020: 03/04/2020 09/9/1987: 09/09/1987 9/09/1987: 09/09/1987 09/09/1987: 09/09/1987 12/12/2000: 12/12/2000 12/6/2000: 12/06/2000 6/12/2000: 06/12/2000 The code assumes a well-formed date, but would leave the majority of random strings unaffected. I'm too lazy to generate other solutions and benchmark them, but you could gather the solutions you receive and benchmark them against each other. Of course, if you mean efficiency in the golf sense, you could do much better than this. Regards, Ian