in reply to Best way to parse my data
You can do it with one regexp actually:
use warnings; use strict; $_ = join"", <DATA>; while(/^B\s+(\w+)\s+(\w+)\s+(ONLINE)(?=.*^G\s+\1\b)/msg) { print "Group '$1' is frozen on host '$2'.\n" } __DATA__ B group1 host1 ONLINE B group1 host2 OFFLINE B group2 host2 ONLINE B group2 host3 OFFLINE B group3 host3 ONLINE B group4 host1 ONLINE B group5 host3 ONLINE G group2 G group3
|
|---|