1

私はperlの新人で、これを行う方法がわかりません...

私の入力ファイル:

random text 00:02 23
random text 00:04 25
random text 00:06 53
random text 00:07 56
random text 00:12 34
 ... etc until 23:59

次の出力が必要です。

00:00
00:01
00:02 23
00:03
00:04
00:05
00:06 53
00:07 56
00:08
00:09
00:10
00:11
00:12 34
... etc until 23:59

したがって、毎分タイムスタンプを含む出力ファイルと、入力ファイルにある場合は対応する値。入力ファイルが 00:00 に始まり、23:59 に終わる

私のコードソファ:

 use warnings;
 use strict;

 my $found;
 my @event;
 my $count2;

 open (FILE, '<./input/input.txt');
 open (OUTPUT, '>./output/output.txt');


    while (<FILE>){
           for ($count2=0; $count2<60; $count2++){

                my($line) = $_;

                if($line =~ m|.*(00:$count2).*|){
                $found = "$1 \n";
                push @event, $found;     
                }

                if (@event){
                }
                else {                                                      
                    $found2 = "00:$count2,";
                    push @event, $found2;   

                }         
                }                    
                }
                print OUTPUT (@event);

               close (FILE);
               close (OUTPUT);
4

2 に答える 2