#!/usr/bin/env perl # # file-age-alert - prints a message when a file is over a given age # # $Id$ use strict; use warnings; use Getopt::Std; my %opt; getopts( 'f:hn:qx:', \%opt ) or die "cannot parse command line\n"; $opt{h} and HELP_MESSAGE(); sub HELP_MESSAGE { print STDERR <= $opt{n} && ( !defined( $opt{x} ) || $age <= $opt{x} ) ) { ++$nr_old_files; next if $opt{q}; my $msg = $opt{f}; my $sex = $msg =~ /%m/ ? $age % 60 : $age; $msg = replace_with_in( '%f', $ARGV[0], $msg ); $msg = replace_with_in( '%m', int( $age / 60 ), $msg ); $msg = replace_with_in( '%s', $sex, $msg ); print $msg, "\n"; } } exit($nr_old_files)