billie_t has asked for the wisdom of the Perl Monks concerning the following question:

I'm having a few problems with syntax using this module. It doesn't help that I'm an utter newbie in Perl. I have read the documentation, but am unable to make much sense of it.

I want to put a file creation date (year, month, day, hour, time) into a variable. I've gotten as far as this:
my $filetime = Win32::FileTime->new($file); my @CreateTime = $filetime->Create (@year, month, day, hour, minute);
Which is pretty much how it's written in the doc. The second line is incorrect because I don't know the correct syntax for the (year, month, day...) arguments.

Your help much appreciated!

Replies are listed 'Best First'.
Re: Advice on Win32::Filetime
by BrowserUk (Patriarch) on Apr 15, 2003 at 23:49 UTC

    If you want all the information, you dont need to specify any parameters.

    my @CreateTime = $filetime->Create();

    will put all the values: year, month, day, hour, minute, second, into the @CreateTime0..5;

    If you only want a subset of these fields, then you can select them by suppling names of those you require:

    my @CreateTime = $filetime->Create( qw[hour minute second] );

    Examine what is said, not who speaks.
    1) When a distinguished but elderly scientist states that something is possible, he is almost certainly right. When he states that something is impossible, he is very probably wrong.
    2) The only way of discovering the limits of the possible is to venture a little way past them into the impossible
    3) Any sufficiently advanced technology is indistinguishable from magic.
    Arthur C. Clarke.
Re: Advice on Win32::Filetime
by rob_au (Abbot) on Apr 16, 2003 at 01:49 UTC
    In addition to the excellent direction from BrowserUK above, I would additionally direct you to the node on this site where thunders posted this code originally here. The main thing which has caught you in this instance is the usage of the literal terms 'year', 'month' and alike for returning the corresponding values.

     

    perl -le 'print+unpack("N",pack("B32","00000000000000000000001001001100"))'

      Thanks, blindingly obvious when I see it now. And thanks for the pointer to the node with the useful info. It's all a learning experience...
Re: Advice on Win32::Filetime
by thunders (Priest) on Apr 25, 2003 at 15:14 UTC
    Update:replaced the misleading term "array" with "list" as pointed out by PodMaster

    just to clarify The possible arguments to the $filetime->Create() method are as follows.

    year, month, wday, day, hour, minute, second, msecond

    wday is the day of the week, and msecond is the number of millisecond. If you dont specify any arguments to Create() you will get an eight element list, with the time fields in that order. I would use the following snippet for what you want

    my $filetime = Win32::FileTime->new($file); my ($year,$month,$day,$hour,$minute) = $filetime->Create (qw[year month day hour minute]);