码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2018-08-12 15:43:34      阅读:339      评论:0      收藏:0      [点我收藏+]

标签:sub   card   ble   decode   xss   view   shift   hang   cell   

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

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

标签:sub   card   ble   decode   xss   view   shift   hang   cell   

原文地址:https://www.cnblogs.com/ajanuw/p/9462756.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!