Perl help LocalTime in New Format

Hi,

I'm new to perl scripting and am trying it out.

I have a file written in the following format:

myfile-MMDDYY where MM is the number of the Month; DD the Day and YY the last two of the year... (Apologies for dumbing this down; I'm trying to be clear).

There is a new file put onto my server everyday by a vendor and I would like to log the fact that the file is present.

So when I grab today's date in Perl I get:

perl -e 'localtime()'

which presents the date in this format:

Tue Oct 18 15:25:47 2011

How would I go about grabbing the date in the other format from this line?

Thanks,

perl -e 'localtime()' prints nothing, and I wouldn't have expected it to. It doesn't print anything, just returns a list or scalar.

perldoc -f localtime has these suggestions for getting dates as you want:

                   use POSIX qw(strftime);
                   $now_string = strftime "%a %b %e %H:%M:%S %Y", localtime;
                   # or for GMT formatted appropriately for your locale:
                   $now_string = strftime "%a %b %e %H:%M:%S %Y", gmtime;

And suggests man strftime for an explanation of the strings strftime takes.

Thanks, that helps.

---------- Post updated at 07:18 PM ---------- Previous update was at 06:54 PM ----------

perl -MPOSIX -e 'print POSIX::strftime("%m%d%y",localtime),"\n"'