You're cool, man. ;-)
--
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 Fri, 1 Feb 2002, Craig S. Cottingham wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> 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
>
> The pathological solution:
>
> my $date = '9/9/1973'; $date =~ s=9/9/1973=09/09/1973=;
>
> On Friday, February 1, 2002, at 04:27 , Robert G. Werner wrote:
>
> > 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.
>
> The been-watching-too-much-Perl-golfing-from-the-sidelines solution:
>
> my $date = '9/9/1973';
> my
> @d=split("/",$date);$date=join"/",(map{("0".$_)=~/(\d\d)$/;$1}@d[0..1]),$d[
> 2];
>
> - --
> Craig S. Cottingham
> [EMAIL PROTECTED]
> PGP key available from:
> <http://pgp.ai.mit.edu:11371/pks/lookup?op=get&search=0xA2FFBE41>
> ID=0xA2FFBE41, fingerprint=6AA8 2E28 2404 8A95 B8FC 7EFC 136F
> 0CEF A2FF BE41
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.0.6 (Darwin)
> Comment: For info see http://www.gnupg.org
>
> iD8DBQE8Wy33E28M76L/vkERAtYkAKCpDvnqszXre7561ygIZK1t6rkd4ACbB8A7
> YFcVGYbsw1fmddgMuHDuP9I=
> =7FHN
> -----END PGP SIGNATURE-----
>