Skip to content

Instantly share code, notes, and snippets.

@yukidarake
Created June 18, 2012 11:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yukidarake/2947999 to your computer and use it in GitHub Desktop.
Save yukidarake/2947999 to your computer and use it in GitHub Desktop.
config.hogeというfunctionブロックを除去し、インデントを一つ下げる
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