Last active
August 29, 2015 14:05
-
-
Save gofer/61b93580a16d198979e6 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 | |
################################################################################ | |
# Vyattaのhoeg{~~~}形式をset ~~~形式に変換するスクリプト | |
################################################################################ | |
use strict; | |
use warnings; | |
use constant true => 1; | |
use constant false => 0; | |
use constant DefaultInputFile => 'settings.txt'; | |
my $inputFile = exists($ARGV[0]) ? $ARGV[0] : DefaultInputFile; | |
my @stack = (); | |
if( !open(FILE, $inputFile) ) { | |
print "Error! - No such file \"$inputFile\".\n"; | |
exit; | |
} | |
while(<FILE>) { | |
$_ =~ s/^(\s*)//g; | |
$_ =~ s/(\s*)$//g; | |
if($_ =~ /^(\s*)([a-zA-Z0-9 \-\.\/]+) {/) { | |
push(@stack, $2); | |
} elsif($_ =~ /^(\s*)}$/) { | |
pop(@stack); | |
} else { | |
print "set @stack $_\n"; | |
} | |
} | |
close(FILE); | |
__END__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment