#!/usr/bin/perl use Text::RewriteRules; my (%ST, $STS); undef $/; my $foo = expand(bbl2html(<>)); $foo =~ s/\n//g; print myformat($foo."\n"); RULES myformat ^<\/div>==> ><==>>\n< ENDRULES sub save { my $foo = shift; $ST{++$STS} = $foo; return "#$STS" } sub load { my $v = shift; return $ST{$v} || ""; } RULES expand #(\d+)=e=>load($1) ENDRULES RULES bbl2html \\url\{([^\}]+)\}=e=>$a=save($1);"$a" bibitem\[[^]]+\]==>bibitem \\bibitem\{([^\}]+)\}==>