Read the docs for eval. With eval { BLOCK } the code in BLOCK is parsed at 'compile' time. With eval $string the code in $string can not be parsed until 'runtime'. use is executed before runtime. Perhaps your evals worked when the contents were strings. Perhaps you want to use require (update: I see you have an import list...That would require SOAP::Lite->import(@list). And you probably want to wrap this logic in a BEGIN {} block.