How about 'rescue => e' instead of '$!' ?