Understood

This is what I have so far...

#!/usr/bin/perl use strict; use warnings; use Text::CSV; use Date::Calc qw(:all); use Date::Calendar; #------------------------------------------- # #------------------------------------------- #--------------------------------------- # Edit Custom Variables Below #--------------------------------------- #-------------------------------- # Input and Output files #-------------------------------- #IN is the directory/filename.csv that the input csv is being written +to #OUT is the directory/filename.csv that the output csv #my $in = '/opt/data/input.csv'; #my $out = '/opt/data/output.csv'; my $in = 'c:/Users/cottenr/test.csv'; my $out = 'c:/Users/cottenr/foo.csv'; my $employee_number; my $employee_id; my $start_date; my $end_date; my $total_days; #--------------------------------------- # Program and Loop Section #--------------------------------------- #Looking for csv file to be written #START: while ( -e $in){ my $csv = Text::CSV->new ({ binary => 1, auto_diag => 1, sep_char => ',' # not really needed as this is the default }); #Open IN and OUT files open(my $data, '<:encoding(utf8)', $in) or die "Could not open '$in' f +ile \n"; <$data>; #skips header line of .csv file open(OUT, '>encoding(utf8)', $out) or die "Could not open '$out' file\ +n"; #Loop through the file and process data while (my $fields = $csv->getline( $data )) { $employee_number = $fields->[2]; $employee_id = $fields->[4]; $start_date = $fields->[17]; $end_date = $fields->[18]; $total_days = $fields->[21]; #Conditional eval for Date Comparison if($end_date > $highnumber) { } elsif ($count > $mednumber) { } else { } #Layout the format and write to OUT file print OUT "$employee_number, $employee_id, $start_date, $end_date, $to +tal_days\n"; } #While loop if (not $csv->eof) { $csv->error_diag(); } #--------------------------------------- # Finish it up! #--------------------------------------- #Print out the footer #Close the IN and OUT files close $data; close $in; close OUT; #Delete the INPUT csv file #unlink $in; } #--------------------------------------- # Take a Nap and do it all over again #--------------------------------------- #sleep 60; #goto START;

Not sure how to go about pulling the first line of the Array and then searching for other matches to see if the Start date -2days of line 2 is the enddate of line 1. If it matches then add total time and update my enddate on the OUT.

Thanks, Ray

In reply to Re^2: Date::Calc and comparing across arrays? by rcotten
in thread Date::Calc and comparing across arrays? by rcotten

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.