遍历文件,读取.wxss文件,在头部添加一条注释

change.pl

#!/usr/bin/perl
use autodie;
use utf8;
use Encode qw(decode encode);
use v5.26;
my $path = shift @ARGV; sub scan_file{
my $path = shift @_;
for(<$path/*>){
if(-d $_){
scan_file($_);
}else{
if(/.wxss$/){
print "$_\n";
my @data = ("/*postcss-pxtransform disable*/\n");
open of, "<", $_; my $path = $_;
while(<of>){
chomp;
push @data, $_;
}
open wf, ">", $path;
print wf @data;
}
}
}
} scan_file($path);

执行

λ perl change.pl .
./weapp_iviewui/iview-weapp/dist/action-sheet/index.wxss
./weapp_iviewui/iview-weapp/dist/alert/index.wxss
./weapp_iviewui/iview-weapp/dist/avatar/index.wxss
./weapp_iviewui/iview-weapp/dist/badge/index.wxss
./weapp_iviewui/iview-weapp/dist/button/index.wxss
./weapp_iviewui/iview-weapp/dist/card/index.wxss
./weapp_iviewui/iview-weapp/dist/cell/index.wxss
./weapp_iviewui/iview-weapp/dist/checkbox/index.wxss
./weapp_iviewui/iview-weapp/dist/checkbox-group/index.wxss
上一篇:SQL语句中单引号、双引号和反引号的区分


下一篇:dfs | Security Badges