MCE::Subs(3)
π MCE::Subs β bestie edition π
okay so this is the MCE::Subs page from the User Contributed Perl Documentation set, and honestly? it's giving "short but mighty" β¨ it's all about exporting plain little functions that are mapped directly to MCE methods. no cap.
πΈ VERSION πΈ
This document describes MCE::Subs version 1.902. yes bestie, that's the one π
β¨ SYNOPSIS β¨
use MCE::Subs; ## Exports manager and worker functions only
## Getter functions are not exported by default
use MCE::Subs qw( :getter ); ## All, including getter functions
use MCE::Subs qw( :manager ); ## Exports manager functions only
use MCE::Subs qw( :worker ); ## Exports worker functions only
use MCE::Subs qw( :getter :worker ); ## Excludes manager functions
okay so lowkey the whole vibe here is: you pick a tag, you get a lil bundle of functions. that's it. that's the tweet π¦
π¦ DESCRIPTION π¦
This module exports functions mapped to MCE methods. All exported functions are prototyped, therefore allowing one to call them without using parentheses. yes, it's giving convenience, it's giving main character energy π
use MCE::Subs qw( :worker );
sub user_func {
my $wid = MCE->wid;
mce_say "A: $wid";
mce_sync;
mce_say "B: $wid";
mce_sync;
mce_say "C: $wid";
mce_sync;
return;
}
MCE->new(
max_workers => 24, user_func => \&user_func
);
mce_run 0 for (1..100); ## 0 means do not shutdown after running
not me writing a whole worker function with zero parens, periodt π
For the next example, we only want the worker functions to be exported, due to using MCE::Map, which takes care of creating a MCE instance and running. so you literally don't have to do anything else π«Ά
use MCE::Map;
use MCE::Subs qw( :worker );
## The following serializes output to STDOUT and gathers $_ to @a.
## mce_say displays $_ when called without arguments.
my @a = mce_map { mce_say; $_ } 1 .. 100;
print scalar @a, "\n";
IMPORTANT LORE, bestie π¨ Unlike the native Perl functions, printf, print, and say methods require the comma after the glob reference or file handle. like, the comma is not optional. it is THE moment. don't skip it π€
MCE->printf(\*STDERR, "%s\n", $error_msg);
MCE->print(\*STDERR, $error_msg, "\n");
MCE->say(\*STDERR, $error_msg);
MCE->say($fh, $error_msg);
mce_printf \*STDERR, "%s\n", $error_msg;
mce_print \*STDERR, $error_msg, "\n";
mce_say \*STDERR, $error_msg;
mce_say $fh, $error_msg;
see how there's no parens version down there? adorable. iconic. slay π β¨
π FUNCTIONS for the MANAGER PROCESS via ( :manager ) π
MCE methods are described in MCE::Core. here's the whole roster, no skips, no cuts π
mce_abortmce_domce_forchunkmce_foreachmce_forseqmce_freezemce_processmce_relay_finalmce_restart_workermce_runmce_printmce_printfmce_saymce_sendmce_shutdownmce_spawnmce_statusmce_thaw
π FUNCTIONS for MCE WORKERS via ( :worker ) π
MCE methods are described in MCE::Core. the worker squad rolls deep π§
mce_abortmce_domce_exitmce_freezemce_gathermce_lastmce_nextmce_printmce_printfmce_relaymce_relay_recvmce_saymce_sendtomce_syncmce_thawmce_yield
π GETTERS for MCE ATTRIBUTES via ( :getter ) π
MCE methods are described in MCE::Core. these are the "lemme just peek at that real quick" functions π
mce_chunk_idmce_chunk_sizemce_max_retriesmce_max_workersmce_pidmce_seedmce_sess_dirmce_task_idmce_task_namemce_task_widmce_tmp_dirmce_user_argsmce_wid
ok and remember: getters are not exported by default β you gotta ask for :getter if you want them. iykyk π
β INDEX β
MCE, MCE::Core
π AUTHOR π
Mario E. Roy, <marioeroy AT gmail DOT com> β thank you for your service, king π«‘π
and that's the whole page bestie!! we ate and left no crumbs β¨π
this was documented under perl v5.42.0 and dated 2025-09-10. love that for us. mwah ππ
πΈ
π¦ where this page comes from
- fedora 43: perl-MCE 1.902-1.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms