Tony,

Tony Cheung wrote:
> I have a perl program about update file from pc to mysql,but I want to 
> limit filesize,how to obtain filesize and file type?
> 

for the file size you can use File::stat

use strict;
use warnings;
use File::stat;

my $file = "C:\\temp\\size.txt";

if ( -e "$file" ) {
   my $stat = stat($file);
   my $size = stat($file)->size;
   print "Size of $file is: " . $size . "\n";
} else {
   print "Could not fine $file\n" && die "\n";
}

for the file type you could query the extension by using a regex. Don't
know what you want to do with the file type, but if you want to exclude
a certain type of files you could do something like

  next if ( ( $file =~ /^.*\.exe$/i ) || ( $file =~ /^.*\.zip$/i ) );

Just a best guess.

Alex
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to