The second one gives you "error 500" because you left out the second quotation mark for the string eval. Also, I'm guessing you're doing this on a web server since Perl itself doesn't sprout error 500. If it's under mod_perl, I wonder if there is a scoping problem. Do you use strict and warnings?

You might also want to use a block eval instead of a string eval. Block eval is for exception handling, string eval is for on-the-fly complilation.

If you're trying to debug this while running it as a CGI, you should serously look into CGI::Carp with particular attention to fatalstobrowser. Or you could do one better and debug it at a command line. It's a much better idea to make sure it compiles at a command line and then upload it to your web server.

Weird. Can you just plain load the module
with use Image::Magick; (or require Image::Magick;)?
In case the machine (or user limit) doesn't provide sufficient memory to load the module (which in theory could be possible), I'd expect that you
get "out of memory" either way.