Sign in to PrePAN

File::Copy::NoClobber Rename copied files safely if destionation exists



    use File::Copy::NoClobber;

    copy( "file.txt", "elsewhere/" ); # elsewhere/file.txt
    copy( "file.txt", "elsewhere/" ); # elsewhere/file (01).txt

    # similar with move
    move( "file.txt", "elsewhere/" ); # elsewhere/file (02).txt

    # import options
    use File::Copy::NoClobber -warn => 1; # warns when name is changed
    use File::Copy::NoClobber -pattern => "[%04d]" # custom noclobber


Wrappers around copy() and move() in File::Copy that check if destionation exists, and if so changes the destination name to something available.


This sounds like a very good idea indeed and the proposed name is entirely appropriate. I look forward to using this module in future - good work!
I second that! Nice idea, and clean code. Great work!

Please sign up to post a review.