{bob is {a cool guy}}
####
is cool guy
####
#!/usr/bin/perl -w
use diagnostics;
use Parse::RecDescent;
use Text::Balanced qw(
extract_bracketed
);
#input
print "Name of file to be inputted? :";
$infile=<>;
print "What should the output file be named? The file will be automatically created. :";
$outfile=<>;
chomp $infile;
$/=undef;
open INFILE, "<$infile";
$text=;
close INFILE;
#processing
my $counter = 0;
while($next = (extract_bracketed($text, '{}', '[^{}]*' ))[0])
{
$holder = $next;
while($bext = (extract_bracketed($next, '{}', '(?s).*?(?=\{code)' ))[0])
{
$bolder = $bext;
while($cext = (extract_bracketed($bext, '{}', '(?s).*?(?=\{escape)' ))[0])
{
$colder = $cext;
$cext =~ s/\{([^ \s|\}]*?)\}/<$1\/>/gix;
$cext =~ s/\{([\w|-]*)(.*)\}/<$1>$2<\/$1>/osi;
$bext =~ s/$colder/$cext/sgi;
}
$bext =~ s/\{(\w*?)\s(.*)\}/\<$1\>$2<\/$1>/gosix;
$bext =~ s/\{metavar(.*?)\}/$1<\/metavar>/gosix;
$bext =~ s/\}/ebrac/g;
$bext =~ s/\{/obrac/g;
$next =~ s/$bolder/$bext/sgi;
}
$next =~ s/\{([^ \s|\}]*?)\}/<$1\/>/gix;
$next =~ s/\{([\w|-]*)(.*)\}/<$1>$2<\/$1>/osi;
$text =~ s/$holder/$next/sgi;
print "Sync check \#$counter\n";
print "$next\n";
$counter++;
}
#output
open FILEOUT, ">$outfile";
print FILEOUT $text;
close FILEOUT;
print "\nYour result is stored in file $outfile\nGoodbye.\n";