I have a test file that looks like that:
t # 3-0, 1
v 0 0
v 1 19
v 2 2
u 0 1 2
u 0 2 2
u 1 2 2
t # 3-1, 1
v 0 0
v 1 15
v 2 2
u 0 1 2
u 0 2 2
u 1 2 2
t # 3-2, 1
v 0 0
v 1 17
v 2 2
u 0 1 2
u 0 2 2
u 1 2 2
t # 3-3, 1
v 0 0
v 1 18
v 2 7
u 0 1 2
u 0 2 2
u 1 2 2
I wrote the following code to match the last three lines of the transaction (each transaction starts with t #)
#!/usr/bin/perl -w
use strict;
my $input = shift @ARGV or die $!;
open (FILE, "$input") or die $!;
LOOP: while (<FILE>) {
if (m/^(t\h*#\h*[0-9,\h-]+)/) {
my $transaction_id = $1;
while (<FILE>) {
if (m/^(u\h+[0]\h+[1]\h+[2])/) {
my $edge_1 = $1;
while (<FILE>) {
if (m/^(u\h+[0]\h+[2]\h+[2])/) {
my $edge_2 = $1;
while (<FILE>) {
if (m/^(u\h+[1]\h+[2]\h+[2])/) {
my $edge_3 = $1;
print $transaction_id . "\t" . $edge_1 . "\t" . $edge_2 . "\t" . $edge_3 . "\n";
next LOOP;
}
}
}
}
}
}
}
}
close FILE;
However, it does not print any results. When I compile my program, it runs without errors. My ultimate goal is to produce output like this, where I output edges of subgraphs "u 0 1 2", "u 0 2 2" and "u 1 2 2":
t # 3-0, 1 u 0 1 2 u 0 2 2 u 1 2 2
t # 3-1, 1 u 0 1 2 u 0 2 2 u 1 2 2
t # 3-2, 1 u 0 1 2 u 0 2 2 u 1 2 2
t # 3-3, 1 u 0 1 2 u 0 2 2 u 1 2 2