Perl 替换字符串应用

2017-06-29 19:36:20来源:CSDN作者:dark5669人点击

Cache all in Perl

use strict;use warnings;print "input filename :  /n";my $filename = <STDIN>;chomp $filename;# drop /n my $data = read_file($filename);$data =~ s/ld.global/ld.global.ca/g;write_file($filename, $data);exit;sub read_file {    my ($filename) = @_;    open my $in, '<:encoding(UTF-8)', $filename or die "Could not open '$filename' for reading $!";    local $/ = undef;    my $all = <$in>;    close $in;    return $all;}sub write_file {    my ($filename, $content) = @_;    open my $out, '>:encoding(UTF-8)', $filename or die "Could not open '$filename' for writing $!";;    print $out $content;    close $out;    return;}

最新文章

123

最新摄影

闪念基因

微信扫一扫

第七城市微信公众平台