The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
#!/usr/bin/perl
use OGDL::Parser;
use Getopt::Std;
%options=();
getopts("d:g:n:p:chro",\%options);

if($#ARGV <0 ||defined $options{h}) {
    print <<END_USAGE;
    $0 [options] path [ogdlfile]
    Create nodes that qualified by path.
END_USAGE

exit;
}


my $g;
my $root="root";
if($#ARGV>0){
    $root=$ARGV[1];
}

my $ogdl=OGDL::Parser->new($root);
if(!$ARGV[1]){
    $ogdl->read(*STDIN);
}
else{
    open my $input, "<$ARGV[1]"  or die "Can't open $ARGV[1]\n";
    $ogdl->read($input);
}
 
$g=$ogdl->parse; 

if(!$g){die "Coundn't parse file: $ARGV[1]\n";}
my $path=$ARGV[0];
$g->gadd($path);


my $depth=0;
my $indent=4;
my $singlequote=1;
my $noblockquote=1;
my $group=-1;
if(exists $options{g}){$group=$options{g};}
if($options{n}){$indent=$options{n};}

open my $output, ">$ARGV[1]" or die "Can't write to $ARGV[1]\n";
my $l=$g->{"list"};
foreach (@$l){
$_->print("filehandle"=>$output,"group"=>$group, "indentwidth"=>$indent,"singlequote"=>$singlequote,"noblockquote"=>$noblockquote);
}