in reply to Best way to parse my data

First off, it's nearly always a good idea to use a CSV module instead of rolling your own. As you have posted no code, I'm assuming you haven't used one. There are a large number, such as Text::CSV, which is a core module(thanks toolic).

The interrelationship between your data are not entirely clear to me based on what you've post, so sorry if I'm off point. Once you've used a CSV module to split your data into a list of lists, you could search through the data for matches using either map/grep or nested foreach loops, which tend to be far more legible.

If your issue is ultimately "I have a list of bad groups (G, term 1) that I need to map to a list of hosts (B, term 2) you should probably use a hash of lists keyed on group where your value is the array of hosts in the group. If you don't want to consider OFFLINE hosts, don't add those elements to your lists.

Update: code:

#!/usr/bin/perl use strict; use warnings; my %group_map = (); while (<DATA>) { my @list = split; if ($list[0] =~ /B/) { my ($group,$host,$online) = @list[1..3]; next if $online =~ /OFFLINE/; # filter "OFFLINE" push @{$group_map{$group}}, $host; next; } if ($list[0] =~ /G/) { my $group = $list[1]; foreach my $host (@{$group_map{$group}}) { print "$group is frozen on $host\n"; } next; } } __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

Replies are listed 'Best First'.
Re^2: Best way to parse my data
by toolic (Bishop) on Sep 30, 2009 at 16:59 UTC
    such as Text::CSV, which is a core module.
    Minor nitpick: Text::CSV is not listed as a Core module according to the latest official documentation page (currently 5.10.1). However, as your link makes clear, it is available for download from CPAN.
Re^2: Best way to parse my data
by sierpinski (Chaplain) on Sep 30, 2009 at 16:56 UTC
    Unfortunately we don't have Text::CSV installed, and I can't figure out why for the life of me. We're not permitted to install or use our own modules. It's a political battle that makes no sense and we always lose.

    Looks like this works perfectly too, thanks to everyone for the responses!
    /\ Sierpinski
        No I hadn't seen it, but thanks so much, I'm definitely doing to check this out!
        /\ Sierpinski