in reply to File "rename" error in renaming a file.

I note that you are performing the rename inside a loop, I suspect you simply need to move it outside the loop.

If that's not it, it would really help to have more information: a short, self-contained, correct example (see SSCCE) would be a great start.

  • Comment on Re: File "rename" error in renaming a file.

Replies are listed 'Best First'.
Re^2: File "rename" error in renaming a file.
by Anonymous Monk on Oct 11, 2022 at 20:14 UTC
    I tried moving it just outside of the "while" loop:
    ... open( ATTA, ">$tempfile" ) || die "Can't open $tempfile: $!"; binmode ATTA; rename $tempfile, "tempdir/".$new_filename or die "Cannot rename fil +e: $!"; } while ( <$attach> ) { ...

    Got this error : " Error calling upload_file: '' is not a filehandle ".