Point being, I can alway run the script that I show to produce the CSV file, but I need help (code) to then evaluate that CSV output

It's very hard not to read the above quote as "write me the code I need". This is not the purpose of the Monastery. We're here to help, not to write code for you. If you want to learn, and you hope to see a code example to get you started on your own solution - look at the following code:

#!/usr/bin/perl use strict; use warnings; # the following line tells Perl not to warn us against comparing # strings to numbers - we want to use this comparison later, # knowing that Perl treats the string '2015-12-01' in numeric context # just the same as the number 2015 no warnings "numeric"; use Time::Piece; my $time = localtime; my $current_year = $time->year; while (my $line = <DATA>) { my ($server, $start_d, $start_t, $end_d, $end_t) = split /,/, $lin +e; if ( $end_d < $current_year ) { print "#OLD# $server,$start_d,$start_t,$end_d,$end_t"; } else { print "$server,$start_d,$start_t,$end_d,$end_t"; } } __DATA__ aaa.aaa.net,2015-01-07,06:45:00,2015-03-31,19:00:00 bbb.bbb.net,2014-06-27,09:25:00,2015-06-27,09:40:00 ccc.ccc.net,2014-12-01,23:15:00,2014-12-06,07:00:00 ddd.ddd.net,2015-01-31,23:15:00,2015-02-23,07:00:00 eee.eee.net,2015-01-30,23:15:00,2015-02-01,07:00:00 fff.fff.net,2014-11-24,12:15:00,2014-11-25,01:00:00 ggg.ggg.net,2014-10-27,09:25:00,2014-12-15,09:40:00 hhh.hhh.net,2015-01-05,23:15:00,2015-02-01,07:00:00 hhh.hhh.net,2015-01-24,18:15:00,2015-02-24,23:00:00

The output:

aaa.aaa.net,2015-01-07,06:45:00,2015-03-31,19:00:00 bbb.bbb.net,2014-06-27,09:25:00,2015-06-27,09:40:00 #OLD# ccc.ccc.net,2014-12-01,23:15:00,2014-12-06,07:00:00 ddd.ddd.net,2015-01-31,23:15:00,2015-02-23,07:00:00 eee.eee.net,2015-01-30,23:15:00,2015-02-01,07:00:00 #OLD# fff.fff.net,2014-11-24,12:15:00,2014-11-25,01:00:00 #OLD# ggg.ggg.net,2014-10-27,09:25:00,2014-12-15,09:40:00 hhh.hhh.net,2015-01-05,23:15:00,2015-02-01,07:00:00 hhh.hhh.net,2015-01-24,18:15:00,2015-02-24,23:00:00

This is a code that solves a problem similar to yours - it operates on your input and it marks all the lines in which the end year is not current as #OLD#.

You should start by making it operate on a file, rather than the DATA section, then focus on comparing the whole date, and not just the year. Some things that will be useful to you, like the Time::Piece module, are already in place. If you are interested in the numeric comparison between '2015-03-31' and the number 2015, and how it works, read the Context tutorial, and you will find the detailed explanation in the 'More flavors of scalars' section. Good luck.

- Luke


In reply to Re^3: Need to check CSV file and identify rows containing old end dates and end times by blindluke
in thread Need to check CSV file and identify rows containing old end dates and end times by SlapShot

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.