sub write() { my $STH = shift; while( @data = $STH->fetchrow_array() ) { ## processing goes here } }