Skip to content

Instantly share code, notes, and snippets.

@mix3
Created September 28, 2015 00:43
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 mix3/c2b4f33fadaa23922098 to your computer and use it in GitHub Desktop.
Save mix3/c2b4f33fadaa23922098 to your computer and use it in GitHub Desktop.
括弧の範囲を探すやーつ
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
my $depth = 0;
my $str = "";
while (<>) {
if (/sqlt_deploy_hook\s+\{/) {
$depth++;
if (/\}/) {
$depth--;
}
$str .= $_;
next;
}
if ($depth) {
if (/\{/) {
$depth++;
}
if (/\}/) {
$depth--;
}
$str .= $_;
}
}
if ($str && $str !~ /next::method/) {
print $str;
exit 1;
}
exit 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment