John McKown wrote: >On Thu, 15 Jan 2004, Andre Chaves Mascarenhas wrote: > >> Hello i wanna know what Perl module can I use and what commands to do the >folowing: >> 1-Check to see if the file is a valid jpg file > >You didn't say what OS. If you're running Linux (or almost any UNIX based >system), then I'd do something like: > >if (`file $file` =~ /JPEG/) { > print "$file appears to be a JPEG file.\n"; >} else { > print "$file does not appear to be a JPEG file.\n"; >} > This will tell you if the filename contains a certain string. That does not make the file a valid image file (besides, there's .jpg and .jpeg, both in uppercase and lowercase, so your pattern should be:
/jpe?g/i if you just want to check the name. - Jan -- There are two major products that come out of Berkeley: LSD and UNIX. We don't believe this to be a coincidence. - Jeremy S. Anderson -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>