{
    "mode": "perldoc",
    "parameter": "POE::Component",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/POE%3A%3AComponent/json",
    "generated": "2026-06-10T16:26:28Z",
    "synopsis": "See specific components.",
    "sections": {
        "NAME": {
            "content": "POE::Component - event driven objects or subsystems\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "See specific components.\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "POE \"components\" are event-driven modules that generally encapsulate mid- to high-level program\nfeatures. For example, POE::Component::Client::DNS performs message-based asynchronous resolver\nlookups. POE::Component::Server::TCP is a basic asynchronous network server.\n\nThe POE::Component namespace was started as place for contributors to publish their POE-based\nmodules without requiring coordination with the main POE distribution. The namespace predates\nthe -X convention, otherwise you'd be reading about POEx instead.\n\nAs with many things in Perl, there is more than one way to implement component interfaces. Newer\ncomponents sport OO interfaces, and some even use Moose, but older ones are solely message\ndriven.\n",
            "subsections": []
        },
        "OBJECT ORIENTED COMPONENTS": {
            "content": "One way to create object-oriented components is to embed a POE::Session instance within an\nobject. This is done by creating the session during the object's constructor, setting the\nsession's alias to something unique, and saving a copy of the alias in the object.\n\npackage Asynchrotron;\n\nmy $aliasindex = 0;\n\nsub new {\nmy $class = shift;\nmy $self = bless {\nalias => PACKAGE . \" \" . ++$aliasindex;\n}, $class;\n\nPOE::Session->create(\nobjectstates => [\n$self => {\nstart       => \"poestart\",\ndosomething => \"poedosomething\",\n},\n],\n);\nreturn $self;\n}\n\nsub poestart {\n$[KERNEL]->aliasset($[OBJECT]->{alias});\n}\n\nThe alias allows object methods to pass events into the session without having to store\nsomething about the session. The POE::Kernel call() transfers execution from the caller\nsession's context into the component's session.\n\nsub dosomething {\nmy $self = shift;\nprint \"Inside the caller's session right now: @\\n\";\n$poekernel->call($self->{alias}, \"dosomething\", @);\n}\n\nsub poedosomething {\nmy @args = @[ARG0..$#];\nprint \"Inside the component's session now: @args\\n\";\n$[OBJECT]{count}++;\n}\n\nBoth $[HEAP] and $[OBJECT] are visible within the component's session. $[HEAP] can be used\nfor ultra-private encapsulation, while $[OBJECT] may be used for data visible by accessors.\n\nsub getcount {\nmy $self = shift;\nreturn $self->{count}; # $[OBJECT]{count} above\n}\n\nToo many sessions may bog down object creation and destruction, so avoid creating them for every\nobject.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "The SEE ALSO section in POE contains a table of contents covering the entire POE distribution.\n\nPOE::Stage is a nascent project to formalize POE components, make POE::Kernel more\nobject-oriented, and provide syntactic and semantic sugar for many common aspects of\nPOE::Component development. It's also easier to type. Please investigate the project. Ideas and\n*tuits* are badly needed to help get the project off the ground.\n",
            "subsections": []
        },
        "TO DO": {
            "content": "Document the customary (but not mandatory!) process of creating and publishing a component.\n\nAUTHORS & COPYRIGHTS\nEach component is written and copyrighted separately.\n\nPlease see POE for more information about authors and contributors.\n",
            "subsections": []
        }
    },
    "summary": "POE::Component - event driven objects or subsystems",
    "flags": [],
    "examples": [],
    "see_also": []
}