use strict; use warnings; my $enddate = todate(); while() { last if ($. > 1 and $enddate < (split /,/)[1]); print $_; } sub todate { my ($year, $month, $day) = (localtime)[5,4,3]; return sprintf "%04d%02d%02d",$year + 1900, $month + 1, $day; } __DATA__ F12,F11,F481,F55,F989 8204B,20161002,1045.469,test,Y 8204,20170112,1064.848,test,Y 8204A,20170113,1064.505,test,Y 8204B,20170114,1045.469,test,Y #### H:\perl>perl 1178418.pl F12,F11,F481,F55,F989 8204B,20161002,1045.469,test,Y 8204,20170112,1064.848,test,Y 8204A,20170113,1064.505,test,Y