#!/usr/local/bin/perl
#
# slice a single field from a ph data file
$fName = shift;

# phase 1: read prod.cnf
$config="prod.cnf";
open (CONFIG,$config) || open (CONFIG,"prod.cnf") || die "Can't open $config.\n";
while (<CONFIG>)
{
  chop;
  if (substr($_,0,1) eq "#") {next;}
  if (length==0) {next;}
  split(/:/);
  if (@_ < 2) {next;}
  if ($_[1] eq $fName) {$fNum = $_[0];last;}
}
close(CONFIG);

if (!$fNum) {die "No field $fName in $config.\n";}

#
# let's go
while(<>)
{
  chop;
  s/^$fNum://;
  s/.*\t$fNum://;
  s/\t.*//;
  print "$_\n";
}
