first comment is the the my $VAR ||= ... lines should just use the = operator and not ||= (since declaring the vars here, obvisouly they are undef so doing the equivalent of my $x = $x || ... doesn't gain anything).
do you have a use Time::localtime; statement in there? To debug, i would Data::Dumper the $ct, $mt, and $at variables and see what's in there. Maybe also dump $sb and $sb->ctime, $sb->mtime, and $sb->atime and hopefully that will reveal the problem.
Update: I see now that you (blackadder) posted this already here: Invalid File Handle??? and that my advice above is same as that given in that thread -- did you follow it? what were the results? I also see you posted that other thread just 3 hours ago .. why don't you wait a little longer before reposting the same issue? | [reply] [d/l] [select] |
I have tried $x = $x instead of $x =||....Nothing happened.
I am using Time ::localtime
I have dumped ctime, atime, mtime,...did not show anything different (i.e it crashes in exat area where the script does)!!!
Will I still get help from the OPEN SOURCE community on PerlMOnks???????????
| [reply] |
I have tried $x = $x instead of $x =||....Nothing happened.
right -- cause they're effectively the same, except one is more confusing to see
I have dumped ctime, atime, mtime,...did not show anything different (i.e it crashes in exat area where the script does)!!!
what is the exact (read: copy past for us please) output if you add this:
use Data::Dumper;
print Dumper $sb;
print Dumper $ct;
print Dumper $mt;
print Dumper $at;
Will I still get help from the OPEN SOURCE community on PerlMOnks???????????
Yes, but in order to help us help you, please carefully review the node How (Not) To Ask A Question (especially this part)
| [reply] [d/l] |
OK,....I have found out why,...Its all because of wondeful Microsoft.
It seems that - well according to M$ - some of our .doc and .xls files were created in the year 1850, 1745 and others in the sixteenth century!!! very impressive isn't it? Anyway, a Microsoft rep has been summoned to come here at once and explain as to why is this….hehehehehe
I am glad that yet again with the use of Perl and the help of PerlMonks I have managed to uncover another outrage from M$... I have been gloating all day about Perl and I love it. :-D
VIVA PERLMONKS,…here here.
BTW : This is my final code with error checks of some sort.
use strict;
use File::Find;
use File::stat;
use File::Spec;
use Time::localtime;
system("cls");
my $start_time = ctime();
print "\nStart Time: $start_time\n\n";
print "Full Path,Size (Byte),Created,Modified,Accessed,File Name,Type\
+n";
find(\&stat_files, @ARGV);
sub stat_files
{
return unless -f;
my $sb = stat ($File::Find::name);
my $size = $sb->size;
my $ct = localtime $sb->ctime;
my $mt = localtime $sb->mtime;
my $at = localtime $sb->atime;
my $creation_time;
my $modified_time;
my $accessed_time;
eval {$creation_time = $ct->mday()."/".($ct->mon()+1)."/".(($ct->y
+ear)+1900);};
$creation_time = '-' if $@;
undef $@;
eval {$modified_time = $mt->mday()."/".($mt->mon()+1)."/".(($mt->y
+ear)+1900);};
$modified_time = '-' if $@;
undef $@;
eval {$accessed_time = $at->mday()."/". ($at->mon()+1)."/".(($at->
+year)+1900);};
$accessed_time = '-' if $@;
undef $@;
my ($volume,$directories,$file) = File::Spec->splitpath($File::Fin
+d::name);
my $ext = $file;
$ext =~ s/.+\.(.+)$//;
$File::Find::name =~ tr/,/-/;
print "$File::Find::name,$size,$creation_time,$modified_time,$acce
+ssed_time,$file,$1\n";
}
my $end_time = ctime();
print "\nEnd Time: $end_time\n";
Thanks a lot guys
*******UPDATE***********
And thanks for the -ve points,...Huh!
| [reply] [d/l] |