|
发表于 2013-2-6 15:59:19
|
显示全部楼层
回复 1# orlye 一个偷懒的办法
用perl 生成一个perl再用生成的perl 去迭代变量,打印出最后的文件
############ test.txt ##############My name is $name.
My ID is $id.
############ 结 果 ##############
My name is eetop.
My ID is 888.
############ 主程序 ##############
#! /usr/bin/perl -w
open Fout , ">sub_var.pl" ;
print Fout '
$name = "eetop" ;
$id = "888" ;
' ;
open Fin , "$ARGV[0]" ;
$file = "" ;
while (<Fin>) {
$file = $file.$_ ;
} ;
close Fin ;
print Fout "
open Fout \, \"\>$ARGV[0]_sub\" \;
print Fout \"$file\" \;
close Fout \;
" ;
print Fout "\n" ;
system "chmod 750 sub_var.pl" ;
system "perl sub_var.pl" ; |
|