perlswitch和case语句
use Net::SMTP;
use HTTP::Date qw(time2iso str2time time2iso time2isoz);
my $CurrTime = time2iso(time());
my $dis_mainpublish='中均资本';
my $menu= <<EOF;
DATE:$CurrTime
--------------------------------------------------
$dis_mainpublish
--------------------------------------------------
****** 1) "清空发布⽬录" *******
****** 2) "获得SQL更新⽬录" *******
****** 3) "更新后同步SVN" *******
****** 4) "退出系统"  *******
EOF
undef @arr1;
undef @arr2;
my $red="\e[1;31m";
my $green="\e[1;32m";
my $yellow="\e[1;33m";
my $normal="\e[0m";
print $menu;
print  "please choose [1-2-3-4]:\n";
chomp (my $val=<STDIN>);
use Switch;
switch ($val) {
case 1 {
print "hints->$red请在svn更新后,在执⾏2操作$normal\n";
if  ( -e "C:\\update") {system("rd /s/q  C\:\\update") };
unless  ( -e "C:\\update"){system("mkdir  C\:\\update") }
}
case 2
{
#$dirname = "C:\\a1";
$dirname="E:\\svn chkout\\Database2.0\\update_sql\\";
opendir ( DIR, $dirname ) || die "Error in opening dir $dirname\n";
while( ($filename = readdir(DIR))){
push @arr1,$filename."\n";
}
closedir(DIR);
sort @arr1;
print @arr1;
>>>>>>>>>>>>>>## $dirname = "C:\\update_sql";
opendir ( DIR, $dirname ) || die "Error in opening dir $dirname\n";
while( ($filename = readdir(DIR))){
push @arr2,$filename."\n";
push @arr2,$filename."\n";
}
closedir(DIR);
sort @arr2;
print @arr2;
@arr2 = grep {$count{$_} == 1 } grep {++$count{$_}} (@arr1, @arr2); print "--------增量信息------------\n";
print "@arr2\n";
use File::Copy::Recursive qw(dircopy);
foreach  (@arr2) {
switch case判断字符串
print "\$_ is $_\n";
chop $_;
my $source_dir="E:\\svn chkout\\Database2.0\\update_sql\\$_";
my $target_dir="C:\\update\\$_";
my $copy_ret=dircopy($source_dir,$target_dir) or die $!;
}
}
case 3          {system("C:\\rsync.bat"); }
else            { exit; }
}

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。

发表评论