{
    "content": [
        {
            "type": "text",
            "text": "# NEXT (man)\n\n## NAME\n\nNEXT - Provide a pseudo-class NEXT (et al) that allows method redispatch\n\n## SYNOPSIS\n\nuse NEXT;\npackage P;\nsub P::method   { print \"$[0]: P method\\n\";   $[0]->NEXT::method() }\nsub P::DESTROY  { print \"$[0]: P dtor\\n\";     $[0]->NEXT::DESTROY() }\npackage Q;\nuse base qw( P );\nsub Q::AUTOLOAD { print \"$[0]: Q AUTOLOAD\\n\"; $[0]->NEXT::AUTOLOAD() }\nsub Q::DESTROY  { print \"$[0]: Q dtor\\n\";     $[0]->NEXT::DESTROY() }\npackage R;\nsub R::method   { print \"$[0]: R method\\n\";   $[0]->NEXT::method() }\nsub R::AUTOLOAD { print \"$[0]: R AUTOLOAD\\n\"; $[0]->NEXT::AUTOLOAD() }\nsub R::DESTROY  { print \"$[0]: R dtor\\n\";     $[0]->NEXT::DESTROY() }\npackage S;\nuse base qw( Q R );\nsub S::method   { print \"$[0]: S method\\n\";   $[0]->NEXT::method() }\nsub S::AUTOLOAD { print \"$[0]: S AUTOLOAD\\n\"; $[0]->NEXT::AUTOLOAD() }\nsub S::DESTROY  { print \"$[0]: S dtor\\n\";     $[0]->NEXT::DESTROY() }\npackage main;\nmy $obj = bless {}, \"S\";\n$obj->method();             # Calls S::method, P::method, R::method\n$obj->missingmethod(); # Calls S::AUTOLOAD, Q::AUTOLOAD, R::AUTOLOAD\n# Clean-up calls S::DESTROY, Q::DESTROY, P::DESTROY, R::DESTROY\n\n## DESCRIPTION\n\nThe \"NEXT\" module adds a pseudoclass named \"NEXT\" to any program that uses it. If a method\n\"m\" calls \"$self->NEXT::m()\", the call to \"m\" is redispatched as if the calling method had\nnot originally been found.\n\n## TLDR\n\n> React framework that uses server-side rendering for building optimized web applications.\n\n- Start the current application in development mode:\n  `next dev`\n- Start the current application and listen on a specific port:\n  `next dev {{-p|--port}} {{port}}`\n- Build the current application optimized for production:\n  `next build`\n- Start the compiled application in production mode:\n  `next start`\n- Start the compiled application and listen on a specific port:\n  `next start {{-p|--port}} {{port}}`\n- Export the current application to static HTML pages:\n  `next export`\n- Display the Next.js telemetry status:\n  `next telemetry`\n- Display help for a subcommand:\n  `next {{build|dev|export|start|telemetry}} {{-h|--help}}`\n\n*Source: tldr-pages*\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION** (4 subsections)\n- **SEE ALSO**\n- **AUTHOR**\n- **BUGS AND IRRITATIONS**\n- **COPYRIGHT**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "NEXT",
        "section": "",
        "mode": "man",
        "summary": "NEXT - Provide a pseudo-class NEXT (et al) that allows method redispatch",
        "synopsis": "use NEXT;\npackage P;\nsub P::method   { print \"$[0]: P method\\n\";   $[0]->NEXT::method() }\nsub P::DESTROY  { print \"$[0]: P dtor\\n\";     $[0]->NEXT::DESTROY() }\npackage Q;\nuse base qw( P );\nsub Q::AUTOLOAD { print \"$[0]: Q AUTOLOAD\\n\"; $[0]->NEXT::AUTOLOAD() }\nsub Q::DESTROY  { print \"$[0]: Q dtor\\n\";     $[0]->NEXT::DESTROY() }\npackage R;\nsub R::method   { print \"$[0]: R method\\n\";   $[0]->NEXT::method() }\nsub R::AUTOLOAD { print \"$[0]: R AUTOLOAD\\n\"; $[0]->NEXT::AUTOLOAD() }\nsub R::DESTROY  { print \"$[0]: R dtor\\n\";     $[0]->NEXT::DESTROY() }\npackage S;\nuse base qw( Q R );\nsub S::method   { print \"$[0]: S method\\n\";   $[0]->NEXT::method() }\nsub S::AUTOLOAD { print \"$[0]: S AUTOLOAD\\n\"; $[0]->NEXT::AUTOLOAD() }\nsub S::DESTROY  { print \"$[0]: S dtor\\n\";     $[0]->NEXT::DESTROY() }\npackage main;\nmy $obj = bless {}, \"S\";\n$obj->method();             # Calls S::method, P::method, R::method\n$obj->missingmethod(); # Calls S::AUTOLOAD, Q::AUTOLOAD, R::AUTOLOAD\n# Clean-up calls S::DESTROY, Q::DESTROY, P::DESTROY, R::DESTROY",
        "tldr_summary": "React framework that uses server-side rendering for building optimized web applications.",
        "tldr_examples": [
            {
                "description": "Start the current application in development mode",
                "command": "next dev"
            },
            {
                "description": "Start the current application and listen on a specific port",
                "command": "next dev {{-p|--port}} {{port}}"
            },
            {
                "description": "Build the current application optimized for production",
                "command": "next build"
            },
            {
                "description": "Start the compiled application in production mode",
                "command": "next start"
            },
            {
                "description": "Start the compiled application and listen on a specific port",
                "command": "next start {{-p|--port}} {{port}}"
            },
            {
                "description": "Export the current application to static HTML pages",
                "command": "next export"
            },
            {
                "description": "Display the Next.js telemetry status",
                "command": "next telemetry"
            },
            {
                "description": "Display help for a subcommand",
                "command": "next {{build|dev|export|start|telemetry}} {{-h|--help}}"
            }
        ],
        "tldr_source": "official",
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 31,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 36,
                "subsections": [
                    {
                        "name": "Enforcing redispatch",
                        "lines": 29
                    },
                    {
                        "name": "Avoiding repetitions",
                        "lines": 98
                    },
                    {
                        "name": "Invoking all versions of a method with a single call",
                        "lines": 65
                    },
                    {
                        "name": "Using \"EVERY\" methods",
                        "lines": 47
                    }
                ]
            },
            {
                "name": "SEE ALSO",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "AUTHOR",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "BUGS AND IRRITATIONS",
                "lines": 8,
                "subsections": []
            },
            {
                "name": "COPYRIGHT",
                "lines": 7,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "NEXT - Provide a pseudo-class NEXT (et al) that allows method redispatch\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "use NEXT;\n\npackage P;\nsub P::method   { print \"$[0]: P method\\n\";   $[0]->NEXT::method() }\nsub P::DESTROY  { print \"$[0]: P dtor\\n\";     $[0]->NEXT::DESTROY() }\n\npackage Q;\nuse base qw( P );\nsub Q::AUTOLOAD { print \"$[0]: Q AUTOLOAD\\n\"; $[0]->NEXT::AUTOLOAD() }\nsub Q::DESTROY  { print \"$[0]: Q dtor\\n\";     $[0]->NEXT::DESTROY() }\n\npackage R;\nsub R::method   { print \"$[0]: R method\\n\";   $[0]->NEXT::method() }\nsub R::AUTOLOAD { print \"$[0]: R AUTOLOAD\\n\"; $[0]->NEXT::AUTOLOAD() }\nsub R::DESTROY  { print \"$[0]: R dtor\\n\";     $[0]->NEXT::DESTROY() }\n\npackage S;\nuse base qw( Q R );\nsub S::method   { print \"$[0]: S method\\n\";   $[0]->NEXT::method() }\nsub S::AUTOLOAD { print \"$[0]: S AUTOLOAD\\n\"; $[0]->NEXT::AUTOLOAD() }\nsub S::DESTROY  { print \"$[0]: S dtor\\n\";     $[0]->NEXT::DESTROY() }\n\npackage main;\n\nmy $obj = bless {}, \"S\";\n\n$obj->method();             # Calls S::method, P::method, R::method\n$obj->missingmethod(); # Calls S::AUTOLOAD, Q::AUTOLOAD, R::AUTOLOAD\n\n# Clean-up calls S::DESTROY, Q::DESTROY, P::DESTROY, R::DESTROY\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "The \"NEXT\" module adds a pseudoclass named \"NEXT\" to any program that uses it. If a method\n\"m\" calls \"$self->NEXT::m()\", the call to \"m\" is redispatched as if the calling method had\nnot originally been found.\n\nNote: before using this module, you should look at next::method\n<https://metacpan.org/pod/mro#next::method> in the core mro module.  \"mro\" has been a core\nmodule since Perl 5.9.5.\n\nIn other words, a call to \"$self->NEXT::m()\" resumes the depth-first, left-to-right search of\n$self's class hierarchy that resulted in the original call to \"m\".\n\nNote that this is not the same thing as \"$self->SUPER::m()\", which begins a new dispatch that\nis restricted to searching the ancestors of the current class. \"$self->NEXT::m()\" can\nbacktrack past the current class -- to look for a suitable method in other ancestors of $self\n-- whereas \"$self->SUPER::m()\" cannot.\n\nA typical use would be in the destructors of a class hierarchy, as illustrated in the\nSYNOPSIS above. Each class in the hierarchy has a DESTROY method that performs some class-\nspecific action and then redispatches the call up the hierarchy. As a result, when an object\nof class S is destroyed, the destructors of all its parent classes are called (in depth-\nfirst, left-to-right order).\n\nAnother typical use of redispatch would be in \"AUTOLOAD\"'ed methods.  If such a method\ndetermined that it was not able to handle a particular call, it might choose to redispatch\nthat call, in the hope that some other \"AUTOLOAD\" (above it, or to its left) might do better.\n\nBy default, if a redispatch attempt fails to find another method elsewhere in the objects\nclass hierarchy, it quietly gives up and does nothing (but see \"Enforcing redispatch\"). This\ngracious acquiescence is also unlike the (generally annoying) behaviour of \"SUPER\", which\nthrows an exception if it cannot redispatch.\n\nNote that it is a fatal error for any method (including \"AUTOLOAD\") to attempt to redispatch\nany method that does not have the same name. For example:\n\nsub S::oops { print \"oops!\\n\"; $[0]->NEXT::othermethod() }\n",
                "subsections": [
                    {
                        "name": "Enforcing redispatch",
                        "content": "It is possible to make \"NEXT\" redispatch more demandingly (i.e. like \"SUPER\" does), so that\nthe redispatch throws an exception if it cannot find a \"next\" method to call.\n\nTo do this, simple invoke the redispatch as:\n\n$self->NEXT::ACTUAL::method();\n\nrather than:\n\n$self->NEXT::method();\n\nThe \"ACTUAL\" tells \"NEXT\" that there must actually be a next method to call, or it should\nthrow an exception.\n\n\"NEXT::ACTUAL\" is most commonly used in \"AUTOLOAD\" methods, as a means to decline an\n\"AUTOLOAD\" request, but preserve the normal exception-on-failure semantics:\n\nsub AUTOLOAD {\nif ($AUTOLOAD =~ /foo|bar/) {\n# handle here\n}\nelse {  # try elsewhere\nshift()->NEXT::ACTUAL::AUTOLOAD(@);\n}\n}\n\nBy using \"NEXT::ACTUAL\", if there is no other \"AUTOLOAD\" to handle the method call, an\nexception will be thrown (as usually happens in the absence of a suitable \"AUTOLOAD\").\n"
                    },
                    {
                        "name": "Avoiding repetitions",
                        "content": "If \"NEXT\" redispatching is used in the methods of a \"diamond\" class hierarchy:\n\n#     A   B\n#    / \\ /\n#   C   D\n#    \\ /\n#     E\n\nuse NEXT;\n\npackage A;\nsub foo { print \"called A::foo\\n\"; shift->NEXT::foo() }\n\npackage B;\nsub foo { print \"called B::foo\\n\"; shift->NEXT::foo() }\n\npackage C; @ISA = qw( A );\nsub foo { print \"called C::foo\\n\"; shift->NEXT::foo() }\n\npackage D; @ISA = qw(A B);\nsub foo { print \"called D::foo\\n\"; shift->NEXT::foo() }\n\npackage E; @ISA = qw(C D);\nsub foo { print \"called E::foo\\n\"; shift->NEXT::foo() }\n\nE->foo();\n\nthen derived classes may (re-)inherit base-class methods through two or more distinct paths\n(e.g. in the way \"E\" inherits \"A::foo\" twice -- through \"C\" and \"D\"). In such cases, a\nsequence of \"NEXT\" redispatches will invoke the multiply inherited method as many times as it\nis inherited. For example, the above code prints:\n\ncalled E::foo\ncalled C::foo\ncalled A::foo\ncalled D::foo\ncalled A::foo\ncalled B::foo\n\n(i.e. \"A::foo\" is called twice).\n\nIn some cases this may be the desired effect within a diamond hierarchy, but in others (e.g.\nfor destructors) it may be more appropriate to call each method only once during a sequence\nof redispatches.\n\nTo cover such cases, you can redispatch methods via:\n\n$self->NEXT::DISTINCT::method();\n\nrather than:\n\n$self->NEXT::method();\n\nThis causes the redispatcher to only visit each distinct \"method\" method once. That is, to\nskip any classes in the hierarchy that it has already visited during redispatch. So, for\nexample, if the previous example were rewritten:\n\npackage A;\nsub foo { print \"called A::foo\\n\"; shift->NEXT::DISTINCT::foo() }\n\npackage B;\nsub foo { print \"called B::foo\\n\"; shift->NEXT::DISTINCT::foo() }\n\npackage C; @ISA = qw( A );\nsub foo { print \"called C::foo\\n\"; shift->NEXT::DISTINCT::foo() }\n\npackage D; @ISA = qw(A B);\nsub foo { print \"called D::foo\\n\"; shift->NEXT::DISTINCT::foo() }\n\npackage E; @ISA = qw(C D);\nsub foo { print \"called E::foo\\n\"; shift->NEXT::DISTINCT::foo() }\n\nE->foo();\n\nthen it would print:\n\ncalled E::foo\ncalled C::foo\ncalled A::foo\ncalled D::foo\ncalled B::foo\n\nand omit the second call to \"A::foo\" (since it would not be distinct from the first call to\n\"A::foo\").\n\nNote that you can also use:\n\n$self->NEXT::DISTINCT::ACTUAL::method();\n\nor:\n\n$self->NEXT::ACTUAL::DISTINCT::method();\n\nto get both unique invocation and exception-on-failure.\n\nNote that, for historical compatibility, you can also use \"NEXT::UNSEEN\" instead of\n\"NEXT::DISTINCT\".\n"
                    },
                    {
                        "name": "Invoking all versions of a method with a single call",
                        "content": "Yet another pseudo-class that \"NEXT\" provides is \"EVERY\".  Its behaviour is considerably\nsimpler than that of the \"NEXT\" family.  A call to:\n\n$obj->EVERY::foo();\n\ncalls every method named \"foo\" that the object in $obj has inherited.  That is:\n\nuse NEXT;\n\npackage A; @ISA = qw(B D X);\nsub foo { print \"A::foo \" }\n\npackage B; @ISA = qw(D X);\nsub foo { print \"B::foo \" }\n\npackage X; @ISA = qw(D);\nsub foo { print \"X::foo \" }\n\npackage D;\nsub foo { print \"D::foo \" }\n\npackage main;\n\nmy $obj = bless {}, 'A';\n$obj->EVERY::foo();        # prints\" A::foo B::foo X::foo D::foo\n\nPrefixing a method call with \"EVERY::\" causes every method in the object's hierarchy with\nthat name to be invoked. As the above example illustrates, they are not called in Perl's\nusual \"left-most-depth-first\" order. Instead, they are called \"breadth-first-dependency-\nwise\".\n\nThat means that the inheritance tree of the object is traversed breadth-first and the\nresulting order of classes is used as the sequence in which methods are called. However, that\nsequence is modified by imposing a rule that the appropriate method of a derived class must\nbe called before the same method of any ancestral class. That's why, in the above example,\n\"X::foo\" is called before \"D::foo\", even though \"D\" comes before \"X\" in @B::ISA.\n\nIn general, there's no need to worry about the order of calls. They will be left-to-right,\nbreadth-first, most-derived-first. This works perfectly for most inherited methods (including\ndestructors), but is inappropriate for some kinds of methods (such as constructors, cloners,\ndebuggers, and initializers) where it's more appropriate that the least-derived methods be\ncalled first (as more-derived methods may rely on the behaviour of their \"ancestors\"). In\nthat case, instead of using the \"EVERY\" pseudo-class:\n\n$obj->EVERY::foo();        # prints\" A::foo B::foo X::foo D::foo\n\nyou can use the \"EVERY::LAST\" pseudo-class:\n\n$obj->EVERY::LAST::foo();  # prints\" D::foo X::foo B::foo A::foo\n\nwhich reverses the order of method call.\n\nWhichever version is used, the actual methods are called in the same context (list, scalar,\nor void) as the original call via \"EVERY\", and return:\n\n•   A hash of array references in list context. Each entry of the hash has the fully\nqualified method name as its key and a reference to an array containing the method's\nlist-context return values as its value.\n\n•   A reference to a hash of scalar values in scalar context. Each entry of the hash has the\nfully qualified method name as its key and the method's scalar-context return values as\nits value.\n\n•   Nothing in void context (obviously).\n"
                    },
                    {
                        "name": "Using \"EVERY\" methods",
                        "content": "The typical way to use an \"EVERY\" call is to wrap it in another base method, that all classes\ninherit. For example, to ensure that every destructor an object inherits is actually called\n(as opposed to just the left-most-depth-first-est one):\n\npackage Base;\nsub DESTROY { $[0]->EVERY::Destroy }\n\npackage Derived1;\nuse base 'Base';\nsub Destroy {...}\n\npackage Derived2;\nuse base 'Base', 'Derived1';\nsub Destroy {...}\n\net cetera. Every derived class than needs its own clean-up behaviour simply adds its own\n\"Destroy\" method (not a \"DESTROY\" method), which the call to \"EVERY::LAST::Destroy\" in the\ninherited destructor then correctly picks up.\n\nLikewise, to create a class hierarchy in which every initializer inherited by a new object is\ninvoked:\n\npackage Base;\nsub new {\nmy ($class, %args) = @;\nmy $obj = bless {}, $class;\n$obj->EVERY::LAST::Init(\\%args);\n}\n\npackage Derived1;\nuse base 'Base';\nsub Init {\nmy ($argsref) = @;\n...\n}\n\npackage Derived2;\nuse base 'Base', 'Derived1';\nsub Init {\nmy ($argsref) = @;\n...\n}\n\net cetera. Every derived class than needs some additional initialization behaviour simply\nadds its own \"Init\" method (not a \"new\" method), which the call to \"EVERY::LAST::Init\" in the\ninherited constructor then correctly picks up.\n"
                    }
                ]
            },
            "SEE ALSO": {
                "content": "mro (in particular next::method <https://metacpan.org/pod/mro#next::method>), which has been\na core module since Perl 5.9.5.\n",
                "subsections": []
            },
            "AUTHOR": {
                "content": "Damian Conway (damian@conway.org)\n",
                "subsections": []
            },
            "BUGS AND IRRITATIONS": {
                "content": "Because it's a module, not an integral part of the interpreter, \"NEXT\" has to guess where the\nsurrounding call was found in the method look-up sequence. In the presence of diamond\ninheritance patterns it occasionally guesses wrong.\n\nIt's also too slow (despite caching).\n\nComment, suggestions, and patches welcome.\n",
                "subsections": []
            },
            "COPYRIGHT": {
                "content": "Copyright (c) 2000-2001, Damian Conway. All Rights Reserved.\nThis module is free software. It may be used, redistributed\nand/or modified under the same terms as Perl itself.\n\n\n\nperl v5.34.0                                 2025-07-25                                  NEXT(3perl)",
                "subsections": []
            }
        }
    }
}