[Perl] cpbak v1.0

作者:reistlin 发布时间:February 23, 2011 分类:原创文章

作者: reistlin
来源: http://www.reistlin.com/blog/173
更新时间: 2011.02
版权声明: 原创文章.转载请保留作者信息和原文完整.谢绝任何方式的摘要

perl.gif

googlecode1.gifgooglecode2.gif
[https://reistlin.googlecode.com/svn/trunk/perl/cpbak.pl]

#!/usr/bin/perl
 
# name: cpbak v1.0
# author: reistlin
# website: www.reistlin.com
# date: 2011.02.22
 
use strict;
use Data::Dumper;
use Time::Local;
 
# debug switch
my $debug = 0;
 
my $name = shift;
my $date = `date +%Y%m%d`;
 
chomp $date;
 
if ( $name ) {
	my $check = index($name, ".");
 
	if ( $check == -1 ) {
        	print `cp -a $name $name.$date`;
        	exit;
	} else {
        	$name =~ m/^(.+)\.(.+)$/;
        	print `cp -a $name $1.$date.$2`;
        	exit;
	}
} else {
	exit;
}

标签: perl

评论已关闭