{
    "content": [
        {
            "type": "text",
            "text": "# Path::Class::File (perldoc)\n\n## NAME\n\nPath::Class::File - Objects representing files\n\n## SYNOPSIS\n\nuse Path::Class;  # Exports file() by default\nmy $file = file('foo', 'bar.txt');  # Path::Class::File object\nmy $file = Path::Class::File->new('foo', 'bar.txt'); # Same thing\n# Stringifies to 'foo/bar.txt' on Unix, 'foo\\bar.txt' on Windows, etc.\nprint \"file: $file\\n\";\nif ($file->isabsolute) { ... }\nif ($file->isrelative) { ... }\nmy $v = $file->volume; # Could be 'C:' on Windows, empty string\n# on Unix, 'Macintosh HD:' on Mac OS\n$file->cleanup; # Perform logical cleanup of pathname\n$file->resolve; # Perform physical cleanup of pathname\nmy $dir = $file->dir;  # A Path::Class::Dir object\nmy $abs = $file->absolute; # Transform to absolute path\nmy $rel = $file->relative; # Transform to relative path\n\n## DESCRIPTION\n\nThe \"Path::Class::File\" class contains functionality for manipulating file names in a\ncross-platform way.\n\n## Sections\n\n- **NAME**\n- **VERSION**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **METHODS**\n- **AUTHOR**\n- **SEE ALSO**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "Path::Class::File",
        "section": "",
        "mode": "perldoc",
        "summary": "Path::Class::File - Objects representing files",
        "synopsis": "use Path::Class;  # Exports file() by default\nmy $file = file('foo', 'bar.txt');  # Path::Class::File object\nmy $file = Path::Class::File->new('foo', 'bar.txt'); # Same thing\n# Stringifies to 'foo/bar.txt' on Unix, 'foo\\bar.txt' on Windows, etc.\nprint \"file: $file\\n\";\nif ($file->isabsolute) { ... }\nif ($file->isrelative) { ... }\nmy $v = $file->volume; # Could be 'C:' on Windows, empty string\n# on Unix, 'Macintosh HD:' on Mac OS\n$file->cleanup; # Perform logical cleanup of pathname\n$file->resolve; # Perform physical cleanup of pathname\nmy $dir = $file->dir;  # A Path::Class::Dir object\nmy $abs = $file->absolute; # Transform to absolute path\nmy $rel = $file->relative; # Transform to relative path",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "VERSION",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 22,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "METHODS",
                "lines": 214,
                "subsections": []
            },
            {
                "name": "AUTHOR",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 2,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "Path::Class::File - Objects representing files\n",
                "subsections": []
            },
            "VERSION": {
                "content": "version 0.37\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "use Path::Class;  # Exports file() by default\n\nmy $file = file('foo', 'bar.txt');  # Path::Class::File object\nmy $file = Path::Class::File->new('foo', 'bar.txt'); # Same thing\n\n# Stringifies to 'foo/bar.txt' on Unix, 'foo\\bar.txt' on Windows, etc.\nprint \"file: $file\\n\";\n\nif ($file->isabsolute) { ... }\nif ($file->isrelative) { ... }\n\nmy $v = $file->volume; # Could be 'C:' on Windows, empty string\n# on Unix, 'Macintosh HD:' on Mac OS\n\n$file->cleanup; # Perform logical cleanup of pathname\n$file->resolve; # Perform physical cleanup of pathname\n\nmy $dir = $file->dir;  # A Path::Class::Dir object\n\nmy $abs = $file->absolute; # Transform to absolute path\nmy $rel = $file->relative; # Transform to relative path\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "The \"Path::Class::File\" class contains functionality for manipulating file names in a\ncross-platform way.\n",
                "subsections": []
            },
            "METHODS": {
                "content": "$file = Path::Class::File->new( <dir1>, <dir2>, ..., <file> )\n$file = file( <dir1>, <dir2>, ..., <file> )\nCreates a new \"Path::Class::File\" object and returns it. The arguments specify the path to\nthe file. Any volume may also be specified as the first argument, or as part of the first\nargument. You can use platform-neutral syntax:\n\nmy $file = file( 'foo', 'bar', 'baz.txt' );\n\nor platform-native syntax:\n\nmy $file = file( 'foo/bar/baz.txt' );\n\nor a mixture of the two:\n\nmy $file = file( 'foo/bar', 'baz.txt' );\n\nAll three of the above examples create relative paths. To create an absolute path, either\nuse the platform native syntax for doing so:\n\nmy $file = file( '/var/tmp/foo.txt' );\n\nor use an empty string as the first argument:\n\nmy $file = file( '', 'var', 'tmp', 'foo.txt' );\n\nIf the second form seems awkward, that's somewhat intentional - paths like \"/var/tmp\" or\n\"\\Windows\" aren't cross-platform concepts in the first place, so they probably shouldn't\nappear in your code if you're trying to be cross-platform. The first form is perfectly fine,\nbecause paths like this may come from config files, user input, or whatever.\n\n$file->stringify\nThis method is called internally when a \"Path::Class::File\" object is used in a string\ncontext, so the following are equivalent:\n\n$string = $file->stringify;\n$string = \"$file\";\n\n$file->volume\nReturns the volume (e.g. \"C:\" on Windows, \"Macintosh HD:\" on Mac OS, etc.) of the object, if\nany. Otherwise, returns the empty string.\n\n$file->basename\nReturns the name of the file as a string, without the directory portion (if any).\n\n$file->components\nReturns a list of the directory components of this file, followed by the basename.\n\nNote: unlike \"$dir->components\", this method currently does not accept any arguments to\nselect which elements of the list will be returned. It may do so in the future. Currently it\nthrows an exception if such arguments are present.\n\n$file->isdir\nReturns a boolean value indicating whether this object represents a directory. Not\nsurprisingly, \"Path::Class::File\" objects always return false, and Path::Class::Dir objects\nalways return true.\n\n$file->isabsolute\nReturns true or false depending on whether the file refers to an absolute path specifier\n(like \"/usr/local/foo.txt\" or \"\\Windows\\Foo.txt\").\n\n$file->isrelative\nReturns true or false depending on whether the file refers to a relative path specifier\n(like \"lib/foo.txt\" or \".\\Foo.txt\").\n\n$file->cleanup\nPerforms a logical cleanup of the file path. For instance:\n\nmy $file = file('/foo//baz/./foo.txt')->cleanup;\n# $file now represents '/foo/baz/foo.txt';\n\n$dir->resolve\nPerforms a physical cleanup of the file path. For instance:\n\nmy $file = file('/foo/baz/../foo.txt')->resolve;\n# $file now represents '/foo/foo.txt', assuming no symlinks\n\nThis actually consults the filesystem to verify the validity of the path.\n\n$dir = $file->dir\nReturns a \"Path::Class::Dir\" object representing the directory containing this file.\n\n$dir = $file->parent\nA synonym for the \"dir()\" method.\n\n$abs = $file->absolute\nReturns a \"Path::Class::File\" object representing $file as an absolute path. An optional\nargument, given as either a string or a Path::Class::Dir object, specifies the directory to\nuse as the base of relativity - otherwise the current working directory will be used.\n\n$rel = $file->relative\nReturns a \"Path::Class::File\" object representing $file as a relative path. An optional\nargument, given as either a string or a \"Path::Class::Dir\" object, specifies the directory\nto use as the base of relativity - otherwise the current working directory will be used.\n\n$foreign = $file->asforeign($type)\nReturns a \"Path::Class::File\" object representing $file as it would be specified on a system\nof type $type. Known types include \"Unix\", \"Win32\", \"Mac\", \"VMS\", and \"OS2\", i.e. anything\nfor which there is a subclass of \"File::Spec\".\n\nAny generated objects (subdirectories, files, parents, etc.) will also retain this type.\n\n$foreign = Path::Class::File->newforeign($type, @args)\nReturns a \"Path::Class::File\" object representing a file as it would be specified on a\nsystem of type $type. Known types include \"Unix\", \"Win32\", \"Mac\", \"VMS\", and \"OS2\", i.e.\nanything for which there is a subclass of \"File::Spec\".\n\nThe arguments in @args are the same as they would be specified in \"new()\".\n\n$fh = $file->open($mode, $permissions)\nPasses the given arguments, including $file, to \"IO::File->new\" (which in turn calls\n\"IO::File->open\" and returns the result as an IO::File object. If the opening fails, \"undef\"\nis returned and $! is set.\n\n$fh = $file->openr()\nA shortcut for\n\n$fh = $file->open('r') or croak \"Can't read $file: $!\";\n\n$fh = $file->openw()\nA shortcut for\n\n$fh = $file->open('w') or croak \"Can't write to $file: $!\";\n\n$fh = $file->opena()\nA shortcut for\n\n$fh = $file->open('a') or croak \"Can't append to $file: $!\";\n\n$file->touch\nSets the modification and access time of the given file to right now, if the file exists. If\nit doesn't exist, \"touch()\" will *make* it exist, and - YES! - set its modification and\naccess time to now.\n\n$file->slurp()\nIn a scalar context, returns the contents of $file in a string. In a list context, returns\nthe lines of $file (according to how $/ is set) as a list. If the file can't be read, this\nmethod will throw an exception.\n\nIf you want \"chomp()\" run on each line of the file, pass a true value for the \"chomp\" or\n\"chomped\" parameters:\n\nmy @lines = $file->slurp(chomp => 1);\n\nYou may also use the \"iomode\" parameter to pass in an IO mode to use when opening the file,\nusually IO layers (though anything accepted by the MODE argument of \"open()\" is accepted\nhere). Just make sure it's a *reading* mode.\n\nmy @lines = $file->slurp(iomode => ':crlf');\nmy $lines = $file->slurp(iomode => '<:encoding(UTF-8)');\n\nThe default \"iomode\" is \"r\".\n\nLines can also be automatically split, mimicking the perl command-line option \"-a\" by using\nthe \"split\" parameter. If this parameter is used, each line will be returned as an array\nref.\n\nmy @lines = $file->slurp( chomp => 1, split => qr/\\s*,\\s*/ );\n\nThe \"split\" parameter can only be used in a list context.\n\n$file->spew( $content );\nThe opposite of \"slurp\", this takes a list of strings and prints them to the file in write\nmode. If the file can't be written to, this method will throw an exception.\n\nThe content to be written can be either an array ref or a plain scalar. If the content is an\narray ref then each entry in the array will be written to the file.\n\nYou may use the \"iomode\" parameter to pass in an IO mode to use when opening the file, just\nlike \"slurp\" supports.\n\n$file->spew(iomode => '>:raw', $content);\n\nThe default \"iomode\" is \"w\".\n\n$file->spewlines( $content );\nJust like \"spew\", but, if $content is a plain scalar, appends $/ to it, or, if $content is\nan array ref, appends $/ to each element of the array.\n\nCan also take an \"iomode\" parameter like \"spew\". Again, the default \"iomode\" is \"w\".\n\n$file->traverse(sub { ... }, @args)\nCalls the given callback on $file. This doesn't do much on its own, but see the associated\ndocumentation in Path::Class::Dir.\n\n$file->remove()\nThis method will remove the file in a way that works well on all platforms, and returns a\nboolean value indicating whether or not the file was successfully removed.\n\n\"remove()\" is better than simply calling Perl's \"unlink()\" function, because on some\nplatforms (notably VMS) you actually may need to call \"unlink()\" several times before all\nversions of the file are gone - the \"remove()\" method handles this process for you.\n\n$st = $file->stat()\nInvokes \"File::stat::stat()\" on this file and returns a File::stat object representing the\nresult.\n\n$st = $file->lstat()\nSame as \"stat()\", but if $file is a symbolic link, \"lstat()\" stats the link instead of the\nfile the link points to.\n\n$class = $file->dirclass()\nReturns the class which should be used to create directory objects.\n\nGenerally overridden whenever this class is subclassed.\n\n$copy = $file->copyto( $dest );\nCopies the $file to $dest. It returns a Path::Class::File object when successful, \"undef\"\notherwise.\n\n$moved = $file->moveto( $dest );\nMoves the $file to $dest, and updates $file accordingly.\n\nIt returns $file is successful, \"undef\" otherwise.\n",
                "subsections": []
            },
            "AUTHOR": {
                "content": "Ken Williams, kwilliams@cpan.org\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "Path::Class, Path::Class::Dir, File::Spec\n",
                "subsections": []
            }
        }
    }
}