#!/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 = ) { my ($server, $start_d, $start_t, $end_d, $end_t) = split /,/, $line; 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