If you can be sure that slashes will be the delimiters,  slit on them
and then add a '0' if the first two elements are less than 10:

my $date_str = "9/9/1973";

my @date_arr = split("/", $date_str);

for my $i (0 .. 1) {
        $date_arr{$i} = $date_arr{$i} < 10 ? $date_arr{$i} : "0$date_arr{$i};
}

$date_str = join("/", @date_arr);

Sort of long to type but that would get the job done IMHO.

-- 
Robert G. Werner
[EMAIL PROTECTED]
2001/9/11

        "Get back to your stations!"
        "We're beaming down to the planet, sir."
                -- Kirk and Mr. Leslie, "This Side of Paradise",
                   stardate 3417.3

On Thu, 31 Jan 2002, Pradeep Sethi wrote:

> Thanks but I am looking of any regexp substitution.
> 
> sorry for typo : I need to change 9/9/1973 to 09/09/1973
> 
> 
> 
> Thanks
> 
> 
> Prad
> 
> 
> > -----Original Message-----
> > From: Bill -OSX- Jones [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, January 31, 2002 5:31 PM
> > To: [EMAIL PROTECTED]
> > Subject: Re: substitution question
> > 
> > 
> > Greetings, On Thursday, January 31, 2002, at 08:17  PM, Pradeep 
> > Sethi wrote:
> > 
> > > Hi All,
> > >
> > > I want to change date 9/9/1987 to 09/09/1973
> > 
> > You want to change 1987 to 1973 ?
> > 
> > > was wondering, what is the most efficient way ?
> > 
> > # Assuming:
> > my ($sec,$min,$hour,$mday,$mon,$year,$wday) = localtime;
> > 
> > # Then -
> > my $vdate = sprintf("%02d", $mon + 1) . '/' . sprintf("%02d", $mday);
> > $vdate .=  '/' . ($year += 1900);
> > 
> > print $vdate; # prints 01/31/2002 or say 01/01/2002
> > 
> > and so on for whichever combinations of month/day/year...
> > 
> > Or a basic program example:
> > http://cpan.valueclick.com/authors/id/S/SN/SNEEX/msg_log.perl_v8s
> > 
> > 
> > No, I am not ignoring the 'efficient' part, but felt this was good 
> > starting spot;
> > HTH/Sx  :]
> > 
> 

Reply via email to