Created
June 18, 2012 11:42
-
-
Save yukidarake/2947999 to your computer and use it in GitHub Desktop.
config.hogeというfunctionブロックを除去し、インデントを一つ下げる
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
for my $js(<*.js>) { | |
open my $new, '>', "$js.2" or die $!; | |
open my $old, '<', $js or die $!; | |
my $spaces = ''; | |
while (my $line = <$old>) { | |
if (!$spaces && (($spaces) = ($line =~ /^(\s+)config.hoge/))) { | |
next; | |
} | |
if ($spaces) { | |
if ($line =~ /^$spaces\}\);/) { | |
$spaces = ''; | |
next; | |
} | |
$line =~ s/$spaces//; | |
print $new $line; | |
next; | |
} | |
print $new $line; | |
} | |
close $old; | |
close $new; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment