App-RegexFileUtils
view release on metacpan or search on metacpan
share/ppt/touch.pl view on Meta::CPAN
#!/usr/local/bin/perl -w
#
# $Id: touch,v 1.2 2004/08/05 14:17:44 cwest Exp $
#
# $Log: touch,v $
# Revision 1.2 2004/08/05 14:17:44 cwest
# cleanup, new version number on website
#
# Revision 1.1 2004/07/23 20:10:18 cwest
# initial import
#
# Revision 1.1 1999/02/28 13:00:24 abigail
# Initial revision
#
#
use strict;
use Getopt::Std;
sub parse_time ($);
my ($VERSION) = '$Revision: 1.2 $' =~ /([.\d]+)/;
my $warnings = 0;
# Print a usuage message on a unknown option.
# Requires my patch to Getopt::Std of 25 Feb 1999.
$SIG {__WARN__} = sub {
require File::Basename;
$0 = File::Basename::basename ($0);
if (substr ($_ [0], 0, 14) eq "Unknown option") {
warn <<EOF;
$0 (Perl bin utils) $VERSION
$0 [-acfm] [-r file] [-t [[CC]YY]MMDDhhmm[.SS]] file [files ...]
EOF
exit;
}
else {
$warnings = 1;
warn "$0: @_";
}
};
$SIG {__DIE__} = sub {
require File::Basename;
$0 = File::Basename::basename ($0);
die "$0: @_";
};
# Get the options.
getopts ('acmfr:t:', \my %options);
warn "Unknown option" unless @ARGV;
my $access_time = exists $options {a} || !exists $options {m};
my $modification_time = exists $options {m} || !exists $options {a};
my $no_create = exists $options {c};
my ($atime, $mtime, $special_time);
if ($options {r}) {
($atime, $mtime) = (stat $options {r}) [8, 9] or die "$options{r}: $!\n";
$special_time = 1;
}
elsif ($options {t}) {
$atime = $mtime = parse_time $options {t};
die "-t $options{t}: Time out of range!\n" if $atime < 0;
$special_time = 1;
}
else {
$atime = $mtime = time;
}
share/ppt/touch.pl view on Meta::CPAN
Set the access time of the specified files only, unless I<-m> is given as
well.
=item -c
Do not create non-existing files. No warning is generated, and it will
not influence the exit status.
=item -f
This option is ignored, and only recognized for compatibility reasons.
=item -m
Set the modification time of the specified files only, unless I<-a> is
given as well.
=item -r file
Use the access and modification time of I<file> instead of the
current time.
=item -t [[CC]YY]MMDDhhmm[.SS]
Set the access and modification times to the specified time.
If B<YY> is present, but B<CC> is not, then B<CC> is assumed to
be 19 if B<YY> is larger than 69, and 20 otherwise. If B<YY>
is not present, the current year is assumed.
It should be noted that many systems cannot deal with timestamps
before Jan 1, 1970 or after Jan 19, 2038.
=back
=head1 ENVIRONMENT
The working of I<touch> is not influenced by any environment variables.
=head1 BUGS
I<touch> does not implement the I<-f> option.
I<touch> uses C<Time::Local> to translate the time format to epoch
seconds
=head1 STANDARDS
This I<head> implementation is compatible with the B<OpenBSD> implementation,
except for the I<-f> option.
=head1 REVISION HISTORY
$Log: touch,v $
Revision 1.2 2004/08/05 14:17:44 cwest
cleanup, new version number on website
Revision 1.1 2004/07/23 20:10:18 cwest
initial import
Revision 1.1 1999/02/28 13:00:24 abigail
Initial revision
=head1 AUTHOR
The Perl implementation of I<touch> was written by Abigail, I<abigail@fnx.com>.
=head1 COPYRIGHT and LICENSE
This program is copyright by Abigail 1999.
This program is free and open software. You may use, copy, modify, distribute
and sell this program (and any modified variants) in any way you wish,
provided you do not restrict others to do the same.
=cut
( run in 0.835 second using v1.01-cache-2.11-cpan-e1769b4cff6 )