john.tm has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/local/bin/perl #use warnings; use strict; use POSIX 'mktime'; use POSIX 'strftime'; my @dateParts = localtime (); my ($day, $month, $year) = @dateParts[3 .. 5]; $year += 1900; $month += 1; open (OUTPUT, '+<', "C:\\temp\\MONTHLY.CSV") or die "Cannot open file + $!\n"; while (defined (my $line = <OUTPUT>)) { chomp $line; my ($Date) = split ',', $line; if ($Date eq "$day $month $year") { close OUTPUT; exit print "\ file has already been updated today"; } elsif ($Date ne "$day $month $year") { # it works fine until i try this #open (INPUT, "C:\\temp\\DAILY.CSV") or die "Cannot open file $!\ +n"; #open (OUTPUT, '>>', "C:\\temp\\MONTHLY.CSV") or die "Cannot open + file $!\n"; #<INPUT>; #while (<INPUT>) { print OUTPUT; } }} #close INPUT; #close OUTPUT;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: check to see if a file has todays data in it, if it has exit if not then add data
by boftx (Deacon) on May 30, 2014 at 01:00 UTC | |
|
Re: check to see if a file has todays data in it, if it has exit if not then add data
by mr_mischief (Monsignor) on May 30, 2014 at 01:19 UTC | |
|
Re: check to see if a file has todays data in it, if it has exit if not then add data
by LanX (Saint) on May 30, 2014 at 00:54 UTC | |
|
Re: check to see if a file has todays data in it, if it has exit if not then add data
by Anonymous Monk on May 30, 2014 at 01:03 UTC | |
by john.tm (Scribe) on Jun 18, 2014 at 22:30 UTC | |
|
Re: check to see if a file has todays data in it, if it has exit if not then add data
by perlfan (Parson) on May 30, 2014 at 12:27 UTC |