应该不是最好的写法,比较难看 你试试下面的,不过好像有点bug, 就是key1, key2 有包含的情况 比如 a , ab , abc
my %hash = (
key1 => replace_key1,
key2 => replace_key2 ,
......
) ;
open my $F1, '<' , $file ;
my $info = do {local $/ ; <$F1> } ;
my $regexp = join "|" , keys %hash ;
$info =~ s/($regexp)/$hash{$1}/mg ;
2009/11/5 sunshine <[email protected]>
> $_=$C;
> 为什么还用这个呢?下面不是有瞄定符了吗?
>
> 用s///mgi会不会更好点呢,多行替换?不清楚,还是perl新手 [?]
>
> >
>
--
Yours Sincerely
Zeng Hong
--~--~---------~--~----~------------~-------~--~----~
您收到此信息是由于您订阅了 Google 论坛“PerlChina Mongers 讨论组”论坛。
要在此论坛发帖,请发电子邮件到 [email protected]
要退订此论坛,请发邮件至 [email protected]
更多选项,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问该论坛
-~----------~----~----~----~------~----~------~--~---
<<inline: 330.gif>>
