#!\Perl

use File::Copy;

sub my_file_name {
	my ($f) = shift;
	my @a = split(/\./, $f);
	my $cnt = scalar @a;
	if ($cnt > 1) {
		pop @a;
		return join( '.', @a);
	}
	return $f;
}

sub my_file_ext {
	my ($f) = shift;
	my @a = split(/\./, $f);
	my $cnt = scalar @a;
	if ($cnt > 1) {
		return $a[-1];
	}
	return '';
}


$fn = 'filename.ext';
$fn1 = 'filename.ext.bak';
$fn2 = 'filename';

print "[$fn] becomes [".my_file_name($fn)."]\n";
print "[$fn1] becomes [".my_file_name($fn1)."]\n";
print "[$fn2] becomes [".my_file_name($fn2)."]\n";
print "[$fn] becomes [".my_file_ext($fn)."]\n";
print "[$fn1] becomes [".my_file_ext($fn1)."]\n";
print "[$fn2] becomes [".my_file_ext($fn2)."]\n";

$fn3 = 'c:/HOMEPAGE/P26/mperl/cldsp.jpg';
$des = 'temp/cldsp.jpg';

copy( $fn3, $des ) or die "Copy FAILED!\n";


