{
    "content": [
        {
            "type": "text",
            "text": "# Term::ReadLine (perldoc)\n\n## NAME\n\nTerm::ReadLine - Perl interface to various \"readline\" packages. If no real package is found, substitutes stubs instead of basic functions.\n\n## SYNOPSIS\n\nuse Term::ReadLine;\nmy $term = Term::ReadLine->new('Simple Perl calc');\nmy $prompt = \"Enter your arithmetic expression: \";\nmy $OUT = $term->OUT || \\*STDOUT;\nwhile ( defined ($ = $term->readline($prompt)) ) {\nmy $res = eval($);\nwarn $@ if $@;\nprint $OUT $res, \"\\n\" unless $@;\n$term->addhistory($) if /\\S/;\n}\n\n## DESCRIPTION\n\nThis package is just a front end to some other packages. It's a stub to set up a common\ninterface to the various ReadLine implementations found on CPAN (under the \"Term::ReadLine::*\"\nnamespace).\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **Minimal set of supported functions**\n- **Additional supported functions**\n- **EXPORTS**\n- **ENVIRONMENT**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "Term::ReadLine",
        "section": "",
        "mode": "perldoc",
        "summary": "Term::ReadLine - Perl interface to various \"readline\" packages. If no real package is found, substitutes stubs instead of basic functions.",
        "synopsis": "use Term::ReadLine;\nmy $term = Term::ReadLine->new('Simple Perl calc');\nmy $prompt = \"Enter your arithmetic expression: \";\nmy $OUT = $term->OUT || \\*STDOUT;\nwhile ( defined ($ = $term->readline($prompt)) ) {\nmy $res = eval($);\nwarn $@ if $@;\nprint $OUT $res, \"\\n\" unless $@;\n$term->addhistory($) if /\\S/;\n}",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 11,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "Minimal set of supported functions",
                "lines": 51,
                "subsections": []
            },
            {
                "name": "Additional supported functions",
                "lines": 61,
                "subsections": []
            },
            {
                "name": "EXPORTS",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "ENVIRONMENT",
                "lines": 17,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "Term::ReadLine - Perl interface to various \"readline\" packages. If no real package is found,\nsubstitutes stubs instead of basic functions.\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "use Term::ReadLine;\nmy $term = Term::ReadLine->new('Simple Perl calc');\nmy $prompt = \"Enter your arithmetic expression: \";\nmy $OUT = $term->OUT || \\*STDOUT;\nwhile ( defined ($ = $term->readline($prompt)) ) {\nmy $res = eval($);\nwarn $@ if $@;\nprint $OUT $res, \"\\n\" unless $@;\n$term->addhistory($) if /\\S/;\n}\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "This package is just a front end to some other packages. It's a stub to set up a common\ninterface to the various ReadLine implementations found on CPAN (under the \"Term::ReadLine::*\"\nnamespace).\n",
                "subsections": []
            },
            "Minimal set of supported functions": {
                "content": "All the supported functions should be called as methods, i.e., either as\n\n$term = Term::ReadLine->new('name');\n\nor as\n\n$term->addhistory('row');\n\nwhere $term is a return value of Term::ReadLine->new().\n\n\"ReadLine\"  returns the actual package that executes the commands. Among possible values are\n\"Term::ReadLine::Gnu\", \"Term::ReadLine::Perl\", \"Term::ReadLine::Stub\".\n\n\"new\"       returns the handle for subsequent calls to following functions. Argument is the name\nof the application. Optionally can be followed by two arguments for \"IN\" and \"OUT\"\nfilehandles. These arguments should be globs.\n\n\"readline\"  gets an input line, *possibly* with actual \"readline\" support. Trailing newline is\nremoved. Returns \"undef\" on \"EOF\".\n\n\"addhistory\"\nadds the line to the history of input, from where it can be used if the actual\n\"readline\" is present.\n\n\"IN\", \"OUT\" return the filehandles for input and output or \"undef\" if \"readline\" input and\noutput cannot be used for Perl.\n\n\"MinLine\"   If argument is specified, it is an advice on minimal size of line to be included\ninto history. \"undef\" means do not include anything into history. Returns the old\nvalue.\n\n\"findConsole\"\nreturns an array with two strings that give most appropriate names for files for\ninput and output using conventions \"<$in\", \">out\".\n\nThe strings returned may not be useful for 3-argument open().\n\nAttribs     returns a reference to a hash which describes internal configuration of the package.\nNames of keys in this hash conform to standard conventions with the leading \"rl\"\nstripped.\n\n\"Features\"  Returns a reference to a hash with keys being features present in current\nimplementation. Several optional features are used in the minimal interface:\n\"appname\" should be present if the first argument to \"new\" is recognized, and\n\"minline\" should be present if \"MinLine\" method is not dummy. \"autohistory\" should\nbe present if lines are put into history automatically (maybe subject to \"MinLine\"),\nand \"addhistory\" if \"addhistory\" method is not dummy.\n\nIf \"Features\" method reports a feature \"attribs\" as present, the method \"Attribs\" is\nnot dummy.\n",
                "subsections": []
            },
            "Additional supported functions": {
                "content": "Actually \"Term::ReadLine\" can use some other package, that will support a richer set of\ncommands.\n\nAll these commands are callable via method interface and have names which conform to standard\nconventions with the leading \"rl\" stripped.\n\nThe stub package included with the perl distribution allows some additional methods:\n\n\"tkRunning\" makes Tk event loop run when waiting for user input (i.e., during \"readline\"\nmethod).\n\n\"eventloop\"\nRegisters call-backs to wait for user input (i.e., during \"readline\" method). This\nsupersedes tkRunning.\n\nThe first call-back registered is the call back for waiting. It is expected that the\ncallback will call the current event loop until there is something waiting to get on\nthe input filehandle. The parameter passed in is the return value of the second call\nback.\n\nThe second call-back registered is the call back for registration. The input\nfilehandle (often STDIN, but not necessarily) will be passed in.\n\nFor example, with AnyEvent:\n\n$term->eventloop(sub {\nmy $data = shift;\n$data->[1] = AE::cv();\n$data->[1]->recv();\n}, sub {\nmy $fh = shift;\nmy $data = [];\n$data->[0] = AE::io($fh, 0, sub { $data->[1]->send() });\n$data;\n});\n\nThe second call-back is optional if the call back is registered prior to the call to\n$term->readline.\n\nDeregistration is done in this case by calling eventloop with \"undef\" as its\nparameter:\n\n$term->eventloop(undef);\n\nThis will cause the data array ref to be removed, allowing normal garbage collection\nto clean it up. With AnyEvent, that will cause $data->[0] to be cleaned up, and\nAnyEvent will automatically cancel the watcher at that time. If another loop\nrequires more than that to clean up a file watcher, that will be up to the caller to\nhandle.\n\n\"ornaments\" makes the command line stand out by using termcap data. The argument to \"ornaments\"\nshould be 0, 1, or a string of a form \"aa,bb,cc,dd\". Four components of this string\nshould be names of *terminal capacities*, first two will be issued to make the\nprompt standout, last two to make the input line standout.\n\n\"newTTY\"    takes two arguments which are input filehandle and output filehandle. Switches to\nuse these filehandles.\n\nOne can check whether the currently loaded ReadLine package supports these methods by checking\nfor corresponding \"Features\".\n",
                "subsections": []
            },
            "EXPORTS": {
                "content": "None\n",
                "subsections": []
            },
            "ENVIRONMENT": {
                "content": "The environment variable \"PERLRL\" governs which ReadLine clone is loaded. If the value is\nfalse, a dummy interface is used. If the value is true, it should be tail of the name of the\npackage to use, such as \"Perl\" or \"Gnu\".\n\nAs a special case, if the value of this variable is space-separated, the tail might be used to\ndisable the ornaments by setting the tail to be \"o=0\" or \"ornaments=0\". The head should be as\ndescribed above, say\n\nIf the variable is not set, or if the head of space-separated list is empty, the best available\npackage is loaded.\n\nexport \"PERLRL=Perl o=0\" # Use Perl ReadLine sans ornaments\nexport \"PERLRL= o=0\"     # Use best available ReadLine sans ornaments\n\n(Note that processing of \"PERLRL\" for ornaments is in the discretion of the particular used\n\"Term::ReadLine::*\" package).\n",
                "subsections": []
            }
        }
    }
}