{
    "content": [
        {
            "type": "text",
            "text": "# Cwd (man)\n\n## NAME\n\nCwd - get pathname of current working directory\n\n## SYNOPSIS\n\nuse Cwd;\nmy $dir = getcwd;\nuse Cwd 'abspath';\nmy $abspath = abspath($file);\n\n## DESCRIPTION\n\nThis module provides functions for determining the pathname of the current working directory.\nIt is recommended that getcwd (or another *cwd() function) be used in all code to ensure\nportability.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION** (2 subsections)\n- **NOTES**\n- **AUTHOR**\n- **COPYRIGHT**\n- **SEE ALSO**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "Cwd",
        "section": "",
        "mode": "man",
        "summary": "Cwd - get pathname of current working directory",
        "synopsis": "use Cwd;\nmy $dir = getcwd;\nuse Cwd 'abspath';\nmy $abspath = abspath($file);",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 6,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 7,
                "subsections": [
                    {
                        "name": "getcwd and friends",
                        "lines": 66
                    },
                    {
                        "name": "$ENV{PWD}",
                        "lines": 7
                    }
                ]
            },
            {
                "name": "NOTES",
                "lines": 8,
                "subsections": []
            },
            {
                "name": "AUTHOR",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "COPYRIGHT",
                "lines": 10,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 5,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "Cwd - get pathname of current working directory\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "use Cwd;\nmy $dir = getcwd;\n\nuse Cwd 'abspath';\nmy $abspath = abspath($file);\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "This module provides functions for determining the pathname of the current working directory.\nIt is recommended that getcwd (or another *cwd() function) be used in all code to ensure\nportability.\n\nBy default, it exports the functions cwd(), getcwd(), fastcwd(), and fastgetcwd() (and, on\nWin32, getdcwd()) into the caller's namespace.\n",
                "subsections": [
                    {
                        "name": "getcwd and friends",
                        "content": "Each of these functions are called without arguments and return the absolute path of the\ncurrent working directory.\n\ngetcwd\nmy $cwd = getcwd();\n\nReturns the current working directory.  On error returns \"undef\", with $! set to indicate\nthe error.\n\nExposes the POSIX function getcwd(3) or re-implements it if it's not available.\n\ncwd\nmy $cwd = cwd();\n\nThe cwd() is the most natural form for the current architecture.  For most systems it is\nidentical to `pwd` (but without the trailing line terminator).\n\nfastcwd\nmy $cwd = fastcwd();\n\nA more dangerous version of getcwd(), but potentially faster.\n\nIt might conceivably chdir() you out of a directory that it can't chdir() you back into.\nIf fastcwd encounters a problem it will return undef but will probably leave you in a\ndifferent directory.  For a measure of extra security, if everything appears to have\nworked, the fastcwd() function will check that it leaves you in the same directory that\nit started in.  If it has changed it will \"die\" with the message \"Unstable directory\npath, current directory changed unexpectedly\".  That should never happen.\n\nfastgetcwd\nmy $cwd = fastgetcwd();\n\nThe fastgetcwd() function is provided as a synonym for cwd().\n\ngetdcwd\nmy $cwd = getdcwd();\nmy $cwd = getdcwd('C:');\n\nThe getdcwd() function is also provided on Win32 to get the current working directory on\nthe specified drive, since Windows maintains a separate current working directory for\neach drive.  If no drive is specified then the current drive is assumed.\n\nThis function simply calls the Microsoft C library getdcwd() function.\n\nabspath and friends\nThese functions are exported only on request.  They each take a single argument and return\nthe absolute pathname for it.  If no argument is given they'll use the current working\ndirectory.\n\nabspath\nmy $abspath = abspath($file);\n\nUses the same algorithm as getcwd().  Symbolic links and relative-path components (\".\"\nand \"..\") are resolved to return the canonical pathname, just like realpath(3).  On error\nreturns \"undef\", with $!  set to indicate the error.\n\nrealpath\nmy $abspath = realpath($file);\n\nA synonym for abspath().\n\nfastabspath\nmy $abspath = fastabspath($file);\n\nA more dangerous, but potentially faster version of abspath.\n"
                    },
                    {
                        "name": "$ENV{PWD}",
                        "content": "If you ask to override your chdir() built-in function,\n\nuse Cwd qw(chdir);\n\nthen your PWD environment variable will be kept up to date.  Note that it will only be kept\nup to date if all packages which use chdir import it from Cwd.\n"
                    }
                ]
            },
            "NOTES": {
                "content": "•   Since the path separators are different on some operating systems ('/' on Unix, ':' on\nMacPerl, etc...) we recommend you use the File::Spec modules wherever portability is a\nconcern.\n\n•   Actually, on Mac OS, the \"getcwd()\", \"fastgetcwd()\" and \"fastcwd()\" functions are all\naliases for the \"cwd()\" function, which, on Mac OS, calls `pwd`.  Likewise, the\n\"abspath()\" function is an alias for \"fastabspath()\".\n",
                "subsections": []
            },
            "AUTHOR": {
                "content": "Originally by the perl5-porters.\n\nMaintained by Ken Williams <KWILLIAMS@cpan.org>\n",
                "subsections": []
            },
            "COPYRIGHT": {
                "content": "Copyright (c) 2004 by the Perl 5 Porters.  All rights reserved.\n\nThis program is free software; you can redistribute it and/or modify it under the same terms\nas Perl itself.\n\nPortions of the C code in this library are copyright (c) 1994 by the Regents of the\nUniversity of California.  All rights reserved.  The license on this code is compatible with\nthe licensing of the rest of the distribution - please see the source code in Cwd.xs for the\ndetails.\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "File::chdir\n\n\n\nperl v5.34.0                                 2025-07-25                                   Cwd(3perl)",
                "subsections": []
            }
        }
    }
}