my $file_to_parse = "Date.csv "; open(FH, '<', $file_to_parse) or error("cannot open file ($!)"); while () { chomp; my ($date, $file_name) = split(","); $date =~ s@\r|\n@@g; # get rid of trailing newlines, however formatted my ($month, $day, $year) = split(m@/@, $date); print "substr $month, 1,2\n"; last; } close (FH);