Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Checking File Types

by Revelation (Deacon)
on Oct 10, 2002 at 02:29 UTC ( [id://204083]=note: print w/replies, xml ) Need Help??


in reply to Checking File Types

In addition to what the previous person said, some shortening of your code:
@alltypes = qw(.gif .jpg .jpeg .jpe .jfif); for (1..5) { # No need for a c-style loop. if param("im$_") { ($filename = $ext = $file = param("im$_")) =~ s/.*[\/\\]//; # +Simultaneous copy/substitute. $ext =~ s/^[^.]*(\.[\w]+$)/$1/; # There are better ways to chec +k for a file, like grepping to make sure the file *ends* in the right + extension, and getting rid of $ext, IMHO, unless you're using the ex +tension somewhere...? unless (grep {$ext eq $_} @alltypes) { error("Your image needs to be a GIF of JPEG file!"); } } }

Gyan Kapur
gyan.kapur@rhhllp.com

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://204083]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-04-18 00:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found