#!/usr/bin/perl

# usage: balance 
# assuming you're bib is on the last page and needs to be balanced,
# this inserts a balance command at the beginning of in the bbl file

$filename = $ARGV[0];
print "balancing $filename.bbl\n";

`head -1 ${filename}.bbl > ${filename}.balance`;
`echo "\\balance" >> $filename.balance`;
`tail +3 $filename.bbl >> $filename.balance`;
`mv -f $filename.balance $filename.bbl`;