Created
September 28, 2015 00:43
-
-
Save mix3/c2b4f33fadaa23922098 to your computer and use it in GitHub Desktop.
括弧の範囲を探すやーつ
This file contains hidden or 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
#!/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