Monday, August 6, 2012

copying a file

use File::Copy; # include this perl module in your program to make this function work

# Function Name : copyFile
# Input            : Source & Destination Location
# Output        : none
# Description    : This function will copy given source file to destination location.
# Created By    : Rinkesh Bansal
#
sub copyFile($$)
{
    my ($source, $target) = @_;
    if (-e $source)
    {
        my $targetdir;
        if (substr($target, -1) eq "/")
        {
            $targetdir = $target;
        }
        else
        {
            $targetdir = substr ($target, 0, rindex($target, "/"));
        }

        copy ($source, $target);
    }
}

No comments:

Post a Comment