andy@mungo[~]$ more cclist while (<>) { if ( /^(\S+)(\s+\d:o(n|ff)){7}/ ) { chomp; my @cols = split; my $service = shift @cols; for ( @cols ) { my ( $level, $status ) = split /:/; print $status eq "on" ? $level : " "; } print "\t$service\n"; } else { print; } }