#!/usr/bin/perl -w use strict; use locale; use warnings; #use diagnostics; use utf8; binmode(STDIN, "encoding(utf8)"); binmode(STDOUT, "encoding(utf8)"); binmode(STDERR, "encoding(utf8)"); my $data_file = "data.txt"; my ($start, $end); open (DATA, '<:utf8', $data_file) || die "Couldn't open $data_file : $!\n"; print "Start time (format : yyyy.mm.dd.hh):\n"; chomp (my $start_input = ); print "End time (format : yyyy.mm.dd.hh):\n"; chomp (my $end_input = ); if ($start_input =~ /\d\d\d\d/ && $end_input =~ /\d\d\d\d/){ while (){ if (/$start_input\d\d\d\d\d\d/ .. /$end_input\d\d\d\d\d\d/){ if ($_ =~ /(.*)\t(.*)\t(.*)/){ print "Date = $1" . "\t" . "Temp_moy_DegCs = $2" . "\t" . "HR_moy_s = $3\n"; } } } } if ($start_input =~ /\d\d\d\d\.\d\d/ && $end_input =~ /\d\d\d\d\.\d\d/){ $start_input =~ tr/\.//d; print "$start_input\n"; $end_input =~ tr/\.//d; print "$end_input\n"; while (){ if (/$start_input\d\d\d\d/ .. /$end_input\d\d\d\d/){ if ($_ =~ /(.*)\t(.*)\t(.*)/){ print "Date = $1" . "\t" . "Temp_moy_DegCs = $2" . "\t" . "HR_moy_s = $3\n"; } } } } close (DATA);