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