With the use of perl regex, if two consecutive lines match than count the number of lines.
I want the number of lines until matches the pattern
D001
0000
open ($file, "$file") || die;
my @lines_f = $file;
my $total_size = $#lines_f +1;
foreach my $line (@lines_f)
{
if ($line =~ /D001/) {
$FSIZE = $k + 1;
} else {
$k++;}
}
Instead of just D001, I also want to check if the next line is 0000. If so $FSIZE is the $file size. The $file would look something like this
00001
00002
.
.
.
D0001
00000
00000
$fileand what would be the expected output for that file. And then show another file that does not containD001, and the corresponding output for that file. For example: "expected output is:$FSIZE = 5" or something like that - Håkon HæglandD0001was missing? - Håkon Hægland