Chinaunix首页 | 论坛 | 博客
  • 博客访问: 25468
  • 博文数量: 13
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 130
  • 用 户 组: 普通用户
  • 注册时间: 2014-01-05 16:13
文章分类
文章存档

2016年(1)

2014年(12)

我的朋友

分类: PERL

2014-01-20 11:30:28

#!/usr/bin/perl -w
use strict;
############ while嵌套循环,内循环中需要打开的文件在内循环中打开
my $ori_mc_config="c:\\tower\\lmsetup\\mc_config_org.txt";
my $mc_config="c:\\tower\\lmsetup\\mc.txt";
my $newfile="c:\\tower\\lmsetup\\mc_config.txt";
#open OLD, "$ori_mc_config"|| die "can't open the file $!";
open NEWF ,">$mc_config"||die "can't open the fiel $!";
open NEWP ,$newfile;
while(my $line=){
#print $line;
if($line=~/^[A-Z]/){             #print out comment lines.If the line start with character A~Z(may commond line)
$line=~/=/;   
my $d=$`; 
 open OLD, "$ori_mc_config"|| die "can't open the file $!";#内循环中打开文件句柄,如果在外循环中打开,则只匹配一次即退出
while(my $old=){              #check old files the configration lines
if($old=~/^[A-Z]/){
if ($old=~/$d/){
#   print $old;
}
}
}  
close OLD;
  
}
else {print $line;}                            #comment lines

  

阅读(1163) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~