use Perl's function for this. Don't know what I was thinking.