in reply to How to copy a file in a perl variable to a directory

The error you are getting is not informative. Add $! to the die string so the reason of the failure is made clear.

Replies are listed 'Best First'.
Re^2: How to copy a file in a perl variable to a directory
by hippo (Archbishop) on Jul 20, 2012 at 14:12 UTC
    Good advice. Since the arguments to copy() are also variables I would always include them in the die string too just to make sure they contain what you think they do.
Re^2: How to copy a file in a perl variable to a directory
by rovf (Priest) on Jul 20, 2012 at 15:58 UTC
    While it is certainly advisable to output $!, it is not always clear whether the reported error relates to the source- or the destination file. This is particularily true in case the code is supposed to run on Windows, where I found that many kinds of access problems lead to the same error string.

    I would therefore also do some basic checks before calling copy, at least: read permission on the source file, write permission for the destination directory.

    -- 
    Ronald Fischer <ynnor@mm.st>