#!/usr/bin/perl use strict; use warnings; my (@cluster1, @cluster2); open FILE, 'dataset.txt'; while (){ my @cols = split /\s+/; if ($cols[0] =~ m/\d/){ if ($cols[2] < 200){ push @cluster1, [@cols]; } else { push @cluster2, [@cols]; } } } # simple test to make sure it worked. foreach my $row (@cluster1) { #print "$cluster1[$row]\n"; print "@$row\n"; }