Well, whats all this mktime/strftime stuff, why aren't you using that? Why did you turn off the free help?
Here is how I'd write it (minimize nesting loops)
Path::Tiny, seek, readline#!/usr/bin/perl -- ## ## 2014-05-29-18:05:27 ## ## perltidy -olq -csc -csci=10 -cscl="sub : BEGIN END if " -otr -opr +-ce -nibc -i=4 -pt=0 "-nsak=*" #!/usr/bin/perl -- use strict; use warnings; use POSIX qw/ strftime /; use Path::Tiny qw/ path /; #~ Main( @ARGV ); Main( 'C:/TEMP/DAILY.csv', 'C:/TEMP/MONTHLY.csv' ); exit( 0 ); sub Main { my( $infile, $outfile ) = @_; if( not has_today( $outfile ) ) { append_today( $infile, $outfile ); ... ## make noise on STDOUT } else { ... ## make noise on STDOUT } } ## end sub Main sub has_today { my( $infile ) = @_; my $today = strftime( '%Y %m %d', localtime ); my $fh = path( $infile )->open_raw; ... ## read last 8k, check for $today } ## assumes infile will fit in memory, if it don't, write more code :) sub append_today { my( $infile, $outfile ) = @_; path( $outfile )->append_raw( path( $infile )->slurp_raw ); }
In reply to Re: check to see if a file has todays data in it, if it has exit if not then add data
by Anonymous Monk
in thread check to see if a file has todays data in it, if it has exit if not then add data
by john.tm
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |