Hehe, MAC OS your script seems to be working perfectly. Thank you for your help!
----- Original Message ----- From: "MAC OS [EMAIL PROTECTED]" <[EMAIL PROTECTED]> To: "John" <[EMAIL PROTECTED]> Cc: "Perl Beginners" <[EMAIL PROTECTED]> Sent: Saturday, February 21, 2004 10:10 PM Subject: Re: Checking about gif > I'm going to top post because it is too long. No need to read the whole > thing. > > I see what you're saying.. > > I'm sorry for my reaction.. > > I've written quite a few scripts since reading Randal's article and I > can assure you that it works as well as file does under UNIX > > Give it a try, modify my original script and you'll love it... > > > #!/usr/bin/perl -w > > use strict; > > die "Usage: $0 directory\n" unless @ARGV > 0; > > use File::Find; > use File::MMagic; > > my $mm = File::MMagic->new; > find sub { > return if -d $_ or -l $_; > my $type = $mm->checktype_filename($_); > return unless $type =~ /gif/i; > print "$File::Find::name: $type\n"; > }, @ARGV; > > Jerry > > > On 21 Feb 2004, at 20:43, John wrote: > > > NAME > > File::MMagic - Guess file type > > > > SYNOPSIS > > use File::MMagic; > > use FileHandle; > > > > $mm = new File::MMagic; # use internal magic file > > # $mm = File::MMagic::new('/etc/magic'); # use external magic > > file > > # $mm = File::MMagic::new('/usr/share/etc/magic'); # if you use > > Debian > > $res = $mm->checktype_filename("/somewhere/unknown/file"); > > > > $fh = new FileHandle "< /somewhere/unknown/file2"; > > $res = $mm->checktype_filehandle($fh); > > > > $fh->read($data, 0x8564); > > $res = $mm->checktype_contents($data); > > > > ABSTRACT > > This perl library uses perl5 objects to guess file type from > > filename > > and/or filehandle. > > > > DESCRIPTION > > checktype_filename(), checktype_filehandle() and checktype_contents > > returns string contains file type with MIME mediatype format. > > > > METHODS > > File::MMagic->new() > > File::MMagic->new( $filename ) > > Initializes the module. If no filename is given, the magic > > numbers > > stored in File::MMagic are used. > > > > $mm->addSpecials > > If a filetype cannot be determined by magic numbers, extra > > checks > > are done based on extra regular expressions which can be > > defined > > here. The first argument should be the filetype, the remaining > > arguments should be one or more regular expressions. > > > > By default, checks are done for message/news, message/rfc822, > > text/html, text/x-roff. > > > > $mm->removeSpecials > > Removes special regular expressions. Specify one or more > > filetypes. > > If no filetypes are specified, all special regexps are removed. > > > > Returns a hash containing the removed entries. > > > > $mm->addFileExts > > If a filetype cannot be determined by magic numbers, extra > > checks > > can be done based on the file extension (actually, a regexp). > > Two > > arguments should be geiven: the filename pattern and the > > corresponding filetype. > > > > By default, checks are done for application/x-compress, > > application/x-bzip2, application/x-gzip, text/html, text/plain > > > > $mm->removeFileExts > > Removes filename pattern checks. Specify one or more patterns. > > If no > > pattern is specified, all are removed. > > ----- Original Message ----- > > From: "Jerry Rocteur" <[EMAIL PROTECTED]> > > To: "John" <[EMAIL PROTECTED]> > > Sent: Saturday, February 21, 2004 9:37 PM > > Subject: Re: Checking about gif > > > > > >> Ridiculous post your POD.. > >> > >> On 21 Feb 2004, at 20:25, John wrote: > >> > >>> Does File::MMagic checks the file headers? > >>> > >>> I read in the POD that checks the file from the filename :) not deep > >>> checking :) > >>> > >>> > >>> ----- Original Message ----- > >>> From: "MAC OS [EMAIL PROTECTED]" <[EMAIL PROTECTED]> > >>> To: "John" <[EMAIL PROTECTED]> > >>> Cc: "Perl Beginners" <[EMAIL PROTECTED]> > >>> Sent: Saturday, February 21, 2004 9:09 PM > >>> Subject: Re: Checking about gif > >>> > >>> > >>>> > >>>> On 21 Feb 2004, at 19:03, John wrote: > >>>> > >>>>> I want to test if a file is a gif image or not. > >>>>> > >>>>> Is it practicable using a module? > >>>> > >>>> perldoc File::MMagic > >>>> > >>>> #!/usr/bin/perl -w > >>>> > >>>> use strict; > >>>> > >>>> die "Usage: $0 directory\n" unless @ARGV > 0; > >>>> > >>>> use File::Find; > >>>> use File::MMagic; > >>>> > >>>> my $mm = File::MMagic->new; > >>>> find sub { > >>>> return if -d $_ or -l $_; > >>>> my $type = $mm->checktype_filename($_); > >>>> return unless $type =~ /gif/i; > >>>> print "$File::Find::name: $type\n"; > >>>> }, @ARGV; > >>>> > >>>> I just happen to be reading an excellent series of articles by > >>>> Randal > >>>> ... You should read them as well... > >>>> > >>>> http://www.google.com/search? > >>>> site=swr&q=site%3Astonehenge.com&as_q=File%3A%3AFind&btnG=Search+sto > >>>> ne > >>>> he > >>>> nge.com+with+Google > >>>> > >>>> Jerry > >>>> > >>>> > >>>> > >>> > >>> > >>> > >>> -- > >>> To unsubscribe, e-mail: [EMAIL PROTECTED] > >>> For additional commands, e-mail: [EMAIL PROTECTED] > >>> <http://learn.perl.org/> <http://learn.perl.org/first-response> > >>> > >> > >> > > > > > > > > -- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > <http://learn.perl.org/> <http://learn.perl.org/first-response> > > > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > <http://learn.perl.org/> <http://learn.perl.org/first-response> > > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>