#!/usr/local/bin/perl while (<>) { @stuff = split; if ($stuff[0] eq "#date") { @labels = @stuff; for ($i = 3; $labels[$i]; $i++) { $idx{$labels[$i]} = $i; } } elsif ($stuff[0] =~ /^\d+-\d+$/) { next if ($stuff[2] == 0); open (BAR, ">$stuff[0].bar") || die "Couldn't make file $stuff[0].bar"; print BAR <