{
    "content": [
        {
            "type": "text",
            "text": "# IO::AtomicFile (perldoc)\n\n## NAME\n\nIO::AtomicFile - write a file which is updated atomically\n\n## SYNOPSIS\n\nuse IO::AtomicFile;\n### Write a temp file, and have it install itself when closed:\nmy $FH = IO::AtomicFile->open(\"bar.dat\", \"w\");\nprint $FH \"Hello!\\n\";\n$FH->close || die \"couldn't install atomic file: $!\";\n### Write a temp file, but delete it before it gets installed:\nmy $FH = IO::AtomicFile->open(\"bar.dat\", \"w\");\nprint $FH \"Hello!\\n\";\n$FH->delete;\n### Write a temp file, but neither install it nor delete it:\nmy $FH = IO::AtomicFile->open(\"bar.dat\", \"w\");\nprint $FH \"Hello!\\n\";\n$FH->detach;\n\n## DESCRIPTION\n\nThis module is intended for people who need to update files reliably in the face of unexpected\nprogram termination.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **AUTHOR** (2 subsections)\n- **REVISION**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "IO::AtomicFile",
        "section": "",
        "mode": "perldoc",
        "summary": "IO::AtomicFile - write a file which is updated atomically",
        "synopsis": "use IO::AtomicFile;\n### Write a temp file, and have it install itself when closed:\nmy $FH = IO::AtomicFile->open(\"bar.dat\", \"w\");\nprint $FH \"Hello!\\n\";\n$FH->close || die \"couldn't install atomic file: $!\";\n### Write a temp file, but delete it before it gets installed:\nmy $FH = IO::AtomicFile->open(\"bar.dat\", \"w\");\nprint $FH \"Hello!\\n\";\n$FH->delete;\n### Write a temp file, but neither install it nor delete it:\nmy $FH = IO::AtomicFile->open(\"bar.dat\", \"w\");\nprint $FH \"Hello!\\n\";\n$FH->detach;",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 17,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 18,
                "subsections": []
            },
            {
                "name": "AUTHOR",
                "lines": 1,
                "subsections": [
                    {
                        "name": "Primary Maintainer",
                        "lines": 2
                    },
                    {
                        "name": "Original Author",
                        "lines": 2
                    }
                ]
            },
            {
                "name": "REVISION",
                "lines": 2,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "IO::AtomicFile - write a file which is updated atomically\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "use IO::AtomicFile;\n\n### Write a temp file, and have it install itself when closed:\nmy $FH = IO::AtomicFile->open(\"bar.dat\", \"w\");\nprint $FH \"Hello!\\n\";\n$FH->close || die \"couldn't install atomic file: $!\";\n\n### Write a temp file, but delete it before it gets installed:\nmy $FH = IO::AtomicFile->open(\"bar.dat\", \"w\");\nprint $FH \"Hello!\\n\";\n$FH->delete;\n\n### Write a temp file, but neither install it nor delete it:\nmy $FH = IO::AtomicFile->open(\"bar.dat\", \"w\");\nprint $FH \"Hello!\\n\";\n$FH->detach;\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "This module is intended for people who need to update files reliably in the face of unexpected\nprogram termination.\n\nFor example, you generally don't want to be halfway in the middle of writing */etc/passwd* and\nhave your program terminate! Even the act of writing a single scalar to a filehandle is *not*\natomic.\n\nBut this module gives you true atomic updates, via rename(). When you open a file */foo/bar.dat*\nvia this module, you are *actually* opening a temporary file */foo/bar.dat..TMP*, and writing\nyour output there. The act of closing this file (either explicitly via close(), or implicitly\nvia the destruction of the object) will cause rename() to be called... therefore, from the point\nof view of the outside world, the file's contents are updated in a single time quantum.\n\nTo ensure that problems do not go undetected, the \"close\" method done by the destructor will\nraise a fatal exception if the rename() fails. The explicit close() just returns undef.\n\nYou can also decide at any point to trash the file you've been building.\n",
                "subsections": []
            },
            "AUTHOR": {
                "content": "",
                "subsections": [
                    {
                        "name": "Primary Maintainer",
                        "content": "Dianne Skoll (dfs@roaringpenguin.com).\n"
                    },
                    {
                        "name": "Original Author",
                        "content": "Eryq (eryq@zeegee.com). President, ZeeGee Software Inc (http://www.zeegee.com).\n"
                    }
                ]
            },
            "REVISION": {
                "content": "$Revision: 1.2 $\n",
                "subsections": []
            }
        }
    }
}