#!/usr/bin/perl -- use strict; use warnings; use POSIX qw/ strftime mktime /; Main( @ARGV ); exit( 0 ); sub Main { ... if( FileUpdatedToday( $filename ) ){ print "\ file has already been updated today"; } else { UpdateFile( $filename ); } if( not -s $temp ){ EmailReport( $temp ); } } sub EmailReport { my( $temp ) = @_; exec $^X, $emailPL, or die "problem with $emailPL"; } sub FileUpdatedToday { ... return !!1; .. return !!0; } sub UpdateFile { ... } #### sub TestFileUpdatedToday { require Test::More; Test::More->import( tests => 4 ); PrepareTestfiles('testfiles'); my $notexist = 'testfiles/notexist'; my $empty = 'testfiles/empty'; my $stale = 'testfiles/stale'; my $updated = 'testfiles/updated'; for my $file ( $notexist , $empty, $stale ){ ok( ! FileUpdatedToday( $file ), "FileUpdatedToday( $file ) should not be true"); } ok( FileUpdatedToday( $updated ), "FileUpdatedToday( $updated ) should be true"); }