On Sat, 02 Feb 2002 17:11:12 +0000, Timothy Johnson wrote:
 
> -----Original Message-----
> > From: Dave Cross
> > To: [EMAIL PROTECTED]
> > Sent: 2/2/02 1:01 AM
> > Subject: Re: Dates in file or directory names ?
> > 
> > On Thu, 31 Jan 2002 21:20:16 +0000, Mark Richmond wrote:
> > 
> >> Ok, so I'm confused
> >> What I want to do is create a directory where the name is the current
> >> date say mkdir(2002131)
> >> What Can't figure out is how to build the date string. I'm sure I'm
> >> just missing something.
> >> Any thoughts.
> > 
> > [can you please try to configure your mail client not to use HTML]
> > 
> > You probably need the "strftime" function from the POSIX module.
> > 
> > my $date = strftime('%Y%m%d', localtime);
>
> Or you can just use localtime();
> 
> ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(); 
> my $date = ($year + 1900).($mon + 1).$mday;
> 
> mkdir($date);

Well perhaps. But that breaks when either $mon or $mday have only one
digit. At which point you'll need to wheel out something like "sprintf" -
so you may as well use "strftime" anyway :)

Dave...

-- 

  Drugs are just bad m'kay

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to