Running a perl script in a rails application

I have a perl script that will be executed in one of my controllers
and will produce text output for a period of time. When I hit my rails
app, the page doesn't render until the perl script has fully completed
running and then I'll see all the output in one shot. I know with CGI
I can just autoflush to see the output as it's produced. Is there some
similar functionality with RoR? Or is there some AJAX solution? I'm
new to rails so any help is much appreciated.