問:如何添加此信息$ sv?用新的替換舊的。增加後用newone替換舊數字
$少stver.php
define('update_ver', 328);
$少rec.pl
#!/usr/bin/perl
$sv="stver.php";
open (NUMECHO, "$sv") || die "Can't open $sv";
while (<NUMECHO>=~m/(\d+)/g) #digits output
{
chomp;
#print "$1\n";
$b=$1;
$a=$b;
++$a;
}
close (NUMECHO);
print "Old value = $b\n";
print "New value = $a\n";
當我運行腳本
$ ./rec.pl
Old value = 328
New value = 329
所有我需要的是329至328更換成stver .php
如果我理解正確的話,以後你運行'rec.pl'你想'stver.php'去讀'define('update_ver',329);'? – MattLBeck 2012-02-29 16:47:18
yeap,它的正確 – user1194977 2012-02-29 16:48:13
[我的字符串中的perl搜索數字]的可能重複(http://stackoverflow.com/questions/9415946/perl-search-digits-in-my-string) – daxim 2012-02-29 17:56:59