{
    "mode": "perldoc",
    "parameter": "ls",
    "section": "-q",
    "url": "https://www.chedong.com/phpMan.php/perldoc/ls/json",
    "generated": "2026-10-05T01:50:58Z",
    "sections": {
        "Found in /usr/share/perl/5.38/pod/perlfaq4.pod": {
            "content": "Why am I getting long decimals (eg, 19.9499999999999) instead of the numbers I should be getting (eg, 19.95)?\nFor the long explanation, see David Goldberg's \"What Every Computer\nScientist Should Know About Floating-Point Arithmetic\"\n(<http://web.cse.msu.edu/~cse320/Documents/FloatingPoint.pdf>).\n\nInternally, your computer represents floating-point numbers in binary.\nDigital (as in powers of two) computers cannot store all numbers\nexactly. Some real numbers lose precision in the process. This is a\nproblem with how computers store numbers and affects all computer\nlanguages, not just Perl.\n\nperlnumber shows the gory details of number representations and\nconversions.\n\nTo limit the number of decimal places in your numbers, you can use the\n\"printf\" or \"sprintf\" function. See \"Floating-point Arithmetic\" in\nperlop for more details.\n\nprintf \"%.2f\", 10/3;\n\nmy $number = sprintf \"%.2f\", 10/3;\n\nHow can I output Roman numerals?\nGet the <http://www.cpan.org/modules/by-module/Roman> module.\n\nHow do I expand function calls in a string?\n(contributed by brian d foy)\n\nThis is documented in perlref, and although it's not the easiest thing\nto read, it does work. In each of these examples, we call the function\ninside the braces used to dereference a reference. If we have more than\none return value, we can construct and dereference an anonymous array.\nIn this case, we call the function in list context.\n\nprint \"The time values are @{ [localtime] }.\\n\";\n\nIf we want to call the function in scalar context, we have to do a bit\nmore work. We can really have any code we like inside the braces, so we\nsimply have to end with the scalar reference, although how you do that\nis up to you, and you can use code inside the braces. Note that the use\nof parens creates a list context, so we need \"scalar\" to force the\nscalar context on the function:\n\nprint \"The time is ${\\(scalar localtime)}.\\n\"\n\nprint \"The time is ${ my $x = localtime; \\$x }.\\n\";\n\nIf your function already returns a reference, you don't need to create\nthe reference yourself.\n\nsub timestamp { my $t = localtime; \\$t }\n\nprint \"The time is ${ timestamp() }.\\n\";\n\nThe \"Interpolation\" module can also do a lot of magic for you. You can\nspecify a variable name, in this case \"E\", to set up a tied hash that\ndoes the interpolation for you. It has several other methods to do this\nas well.\n\nuse Interpolation E => 'eval';\nprint \"The time values are $E{localtime()}.\\n\";\n\nIn most cases, it is probably easier to simply use string concatenation,\nwhich also forces scalar context.\n\nprint \"The time is \" . localtime() . \".\\n\";\n\nHow do I keep persistent data across program calls?\nFor some specific applications, you can use one of the DBM modules. See\nAnyDBMFile. More generically, you should consult the FreezeThaw or\nStorable modules from CPAN. Starting from Perl 5.8, Storable is part of\nthe standard distribution. Here's one example using Storable's \"store\"\nand \"retrieve\" functions:\n\nuse Storable;\nstore(\\%hash, \"filename\");\n\n# later on...\n$href = retrieve(\"filename\");        # by ref\n%hash = %{ retrieve(\"filename\") };   # direct to hash\n",
            "subsections": []
        },
        "Found in /usr/share/perl/5.38/pod/perlfaq8.pod": {
            "content": "How do I trap control characters/signals?\nYou don't actually \"trap\" a control character. Instead, that character\ngenerates a signal which is sent to your terminal's currently\nforegrounded process group, which you then trap in your process. Signals\nare documented in \"Signals\" in perlipc and the section on \"Signals\" in\nthe Camel.\n\nYou can set the values of the %SIG hash to be the functions you want to\nhandle the signal. After perl catches the signal, it looks in %SIG for a\nkey with the same name as the signal, then calls the subroutine value\nfor that key.\n\n# as an anonymous subroutine\n\n$SIG{INT} = sub { syswrite(STDERR, \"ouch\\n\", 5 ) };\n\n# or a reference to a function\n\n$SIG{INT} = \\&ouch;\n\n# or the name of the function as a string\n\n$SIG{INT} = \"ouch\";\n\nPerl versions before 5.8 had in its C source code signal handlers which\nwould catch the signal and possibly run a Perl function that you had set\nin %SIG. This violated the rules of signal handling at that level\ncausing perl to dump core. Since version 5.8.0, perl looks at %SIG after\nthe signal has been caught, rather than while it is being caught.\nPrevious versions of this answer were incorrect.\n\nWhy doesn't open() return an error when a pipe open fails?\nIf the second argument to a piped open() contains shell metacharacters,\nperl fork()s, then exec()s a shell to decode the metacharacters and\neventually run the desired program. If the program couldn't be run, it's\nthe shell that gets the message, not Perl. All your Perl program can\nfind out is whether the shell itself could be successfully started. You\ncan still capture the shell's STDERR and check it for error messages.\nSee \"How can I capture STDERR from an external command?\" elsewhere in\nthis document, or use the IPC::Open3 module.\n\nIf there are no shell metacharacters in the argument of open(), Perl\nruns the command directly, without using the shell, and can correctly\nreport whether the command started.\n",
            "subsections": []
        },
        "Found in /usr/share/perl/5.38/pod/perlfaq9.pod": {
            "content": "How do I extract URLs?\nHTML::SimpleLinkExtor will extract URLs from HTML, it handles anchors,\nimages, objects, frames, and many other tags that can contain a URL. If\nyou need anything more complex, you can create your own subclass of\nHTML::LinkExtor or HTML::Parser. You might even use\nHTML::SimpleLinkExtor as an example for something specifically suited to\nyour needs.\n\nYou can use URI::Find or URL::Search to extract URLs from an arbitrary\ntext document.\n",
            "subsections": []
        }
    },
    "flags": [],
    "examples": [],
    "see_also": []
}