blackadder has asked for the wisdom of the Perl Monks concerning the following question:
And this was the output I got back:#! c:/perl/bin/perl.exe -slw $|++; AUTOLOAD; require 5.008; use strict; use warnings 'all'; use Win32; use Win32::OLE; my $fso = Win32::OLE->new( 'Scripting.FileSystemObject' ); Win32::OLE->Option( Warn => 0 ); my $file = $fso->GetFile("c:\\perl\\bin\\perl.exe"); for my $key (keys %{$file}) { print "$key : $file->{$key}\n"; }
What I am after are the date attributes, however I wondering is there away I can decode those variant (i.e. print out the human readble dates) on the same line or on the fly as per say?C:\Perl\FSO>archive.pl Path : C:\Perl\bin\perl.exe Name : perl.exe ShortPath : C:\perl\bin\perl.exe ShortName : perl.exe Drive : Win32::OLE=HASH(0x1a4a3d0) ParentFolder : Win32::OLE=HASH(0x1a4a3ac) Attributes : 32 DateCreated : Win32::OLE::Variant=SCALAR(0x1a4a3dc) DateLastModified : Win32::OLE::Variant=SCALAR(0x1a4a358) DateLastAccessed : Win32::OLE::Variant=SCALAR(0x1a4a40c) Size : 41033 Type : Application C:\Perl\FSO>
And got the human readable date format. Thanks for listeninguse Win32::OLE::Variant;
and this is the error I got back:#! c:/perl/bin/perl.exe -slw $|++; AUTOLOAD; require 5.008; use strict; use warnings 'all'; use Win32; use Win32::OLE; use Win32::OLE::Variant; my $fso = Win32::OLE->new( 'Scripting.FileSystemObject' ); Win32::OLE->Option( Warn => 0 ); my $file = $fso->GetFile("c:\\perl\\bin\\perl.exe"); for my $key (keys %{$file}) { if ( $key eq 'Drive') { for (keys %{$key->{'Drive'}}) { print "$_ \n"; } } elsif ($key eq 'ParentFolder') { for (keys %{$key->{ParentFolder}}) { print "$_ \n"; } } else { print "$key : $file->{$key}\n"; } }
So I am having problems decoding and OLE hash!C:\Perl\FSO>archive.pl Path : C:\Perl\bin\perl.exe Name : perl.exe ShortPath : C:\perl\bin\perl.exe ShortName : perl.exe Can't use string ("Drive") as a HASH ref while "strict refs" in use at + C:\Perl\F SO\archive.pl line 22. C:\Perl\FSO>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Decoding OLE::Variant
by szbalint (Friar) on Oct 31, 2005 at 11:30 UTC | |
|
Re: Decoding OLE::Variant
by meetraz (Hermit) on Oct 31, 2005 at 22:02 UTC |