use MCE::Loop chunk_size => 1, max_workers => 4; use DBI; sub db_iter { my $dbh = DBI->connect("dbi:SQLite:dbname=sample.db", "", "", { PrintError => 0, RaiseError => 1, AutoCommit => 1, FetchHashKeyName => 'NAME_lc', }); my $sth = $dbh->prepare("select fname, lname from people"); $sth->execute(); return sub { if (my @row = $sth->fetchrow_array) { return @row; } return; } } mce_loop { my ($mce, $chunk_ref, $chunk_id) = @_; my ($fname, $lname) = @{ $chunk_ref }; MCE->say("Hello, $fname $lname"); } db_iter();