{
    "mode": "perldoc",
    "parameter": "File::Touch",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/File%3A%3ATouch/json",
    "generated": "2026-06-12T13:52:04Z",
    "synopsis": "use File::Touch 0.12;\n@filelist = ('one.txt','../two.doc');\n$count = touch(@filelist);\nuse File::Touch;\n$referencefile = '/etc/passwd';\n$touchobj = File::Touch->new(\nreference => $referencefile,\nnocreate => 1\n);\n@filelist = ('one.txt','../two.doc');\n$count     = $touchobj->touch(@filelist);",
    "sections": {
        "NAME": {
            "content": "File::Touch - update file access and modification times, optionally creating files if needed\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use File::Touch 0.12;\n@filelist = ('one.txt','../two.doc');\n$count = touch(@filelist);\n\nuse File::Touch;\n$referencefile = '/etc/passwd';\n$touchobj = File::Touch->new(\nreference => $referencefile,\nnocreate => 1\n);\n@filelist = ('one.txt','../two.doc');\n$count     = $touchobj->touch(@filelist);\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This module provides both a functional and OO interface for changing the file access and\nmodification times on files. It can optionally create the file for you, if it doesn't exist.\n\nNote: you should specify a minimum version of 0.12, as per the SYNOPSIS, as that fixed an issue\nthat affected systems that have sub-second granularity on those file times.\n\nHere's a list of arguments that can be used with the object-oriented contruction:\n\natimeonly => [0|1]\nIf nonzero, change only the access time of files. Default is zero.\n\nmtimeonly => [0|1]\nIf nonzero, change only the modification time of files. Default is zero.\n\nnocreate => [0|1]\nIf nonzero, do not create new files. Default is zero.\n\nreference => $referencefile\nIf defined, use timestamps from this file instead of current time. The timestamps are read\nfrom the reference file when the object is created, not when \"<-\"touch>> is invoked. Default\nis undefined.\n\ntime => $time\nIf defined, then this value will be used for both access time and modification time,\nwhichever of those are set. This time is overridden by the \"atime\" and \"mtime\" arguments, if\nyou use them.\n\natime => $time\nIf defined, use this time (in epoch seconds) instead of current time for access time.\n\nmtime => $time\nIf defined, use this time (in epoch seconds) instead of current time for modification time.\n",
            "subsections": []
        },
        "Examples": {
            "content": "",
            "subsections": [
                {
                    "name": "Update access and modification times, creating nonexistent files",
                    "content": "use File::Touch;\nmy @files = ('one','two','three');\nmy $count = touch(@files);\nprint \"$count files updated\\n\";\n"
                },
                {
                    "name": "Set access time forward, leave modification time unchanged",
                    "content": "use File::Touch;\nmy @files = ('one','two','three');\nmy $day = 24*60*60;\nmy $time = time() + 30 * $day;\nmy $ref = File::Touch->new( atimeonly => 1, time => $time );\nmy $count = $ref->touch(@files);\nprint \"$count files updated\\n\";\n"
                },
                {
                    "name": "Set modification time back, update access time, do not create nonexistent files",
                    "content": "use File::Touch;\nmy @files = ('one','two','three');\nmy $day = 24*60*60;\nmy $time = time() - 30 * $day;\nmy $ref = File::Touch->new( mtime => $time, nocreate => 1 );\nmy $count = $ref->touch(@files);\nprint \"$count files updated\\n\";\n"
                },
                {
                    "name": "Make a change to a file, keeping its timestamps unchanged",
                    "content": "use File::Touch;\nmy $daterestorer = File::Touch->new(reference => $file);\n# Update the contents of $file here.\n$daterestorer->touch($file);\n"
                }
            ]
        },
        "REPOSITORY": {
            "content": "<https://github.com/neilb/File-Touch>\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Nigel Wetters Gourlay (nwetters@cpan.org)\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Copyright (c) 2001,2007,2009 Nigel Wetters Gourlay. All Rights Reserved. This module is free\nsoftware. It may be used, redistributed and/or modified under the same terms as Perl itself.\n",
            "subsections": []
        }
    },
    "summary": "File::Touch - update file access and modification times, optionally creating files if needed",
    "flags": [],
    "examples": [],
    "see_also": []
}