Skip to content

Instantly share code, notes, and snippets.

@gofer
Last active August 29, 2015 14:05
Show Gist options
  • Save gofer/61b93580a16d198979e6 to your computer and use it in GitHub Desktop.
Save gofer/61b93580a16d198979e6 to your computer and use it in GitHub Desktop.
#!/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