home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam

Programming Perl


3.2.186 utime

utime 

LIST

This function changes the access and modification times on each file of a list of files. The first two elements of the list must be the numerical access and modification times, in that order. The function returns the number of files successfully changed. The inode change time of each file is set to the current time. Here's an example of a touch command:

#!/usr/bin/perl
$now = time;
utime $now, $now, @ARGV;

and here's a more sophisticated touch command with a bit of error checking:

#!/usr/bin/perl
$now = time;
@cannot = grep {not utime $now, $now, $_} @ARGV;
die "0ドル: Could not touch @cannot.\n" if @cannot;

The standard touch command will actually create missing files, something like this:

$now = time;
foreach $file (@ARGV) {
 utime $now, $now, $file
 or open TMP, ">>$file"
 or warn "Couldn't touch $file: $!\n";
}

To read the times from existing files, use stat .


3.2.185 use Book Index 3.2.187 values

[ Library Home | Perl in a Nutshell | Learning Perl | Learning Perl on Win32 | Programming Perl | Advanced Perl Programming | Perl Cookbook ]







(追記) (追記ここまで)


(追記) (追記ここまで)


AltStyle によって変換されたページ (->オリジナル) /