Hello!
I have two arrays:
date1:
13:26:10
13:26:11
13:26:12
13:26:13
13:26:14
date2:
13:26:07.1
13:26:08.1
13:26:09.1
13:26:10.1
13:26:11.1
13:26:12.1
13:26:13.1
I would like to compare rows in array date1 and date2, and the rows that have the same time, I want to see.
I have written the code:
However, all the items are displayed in the array date2.
I have the feeling that nothing is inserted into the $ _.
Can someone indicate the error in my code?
I will be very grateful for your help.
I have two arrays:
date1:
13:26:10
13:26:11
13:26:12
13:26:13
13:26:14
date2:
13:26:07.1
13:26:08.1
13:26:09.1
13:26:10.1
13:26:11.1
13:26:12.1
13:26:13.1
I would like to compare rows in array date1 and date2, and the rows that have the same time, I want to see.
I have written the code:
Code:
#!/usr/bin/perl use strict; use warnings; my @date1; my @date2; open (K, 'plik1.txt'); while (<K>) { open (P, 'plik2.txt'); while (<P>) { chomp(@date1 = <K>); chomp(@date2 = <P>); } } close(K); close(P); my @pasuje; my @pas; #my @pasuje; foreach (@date1) { push @pasuje, grep(/^$_/, @date2); print "$_ \n"; } print @pasuje;
I have the feeling that nothing is inserted into the $ _.
Can someone indicate the error in my code?
I will be very grateful for your help.
Comment