#!/usr/bin/perl # # dbcolsplittorows # Copyright (C) 1991-2005 by John Heidemann # $Id: dbcolsplittorows,v 1.3 2005/02/26 18:48:41 johnh Exp $ # # This program is distributed under terms of the GNU general # public license, version 2. See the file COPYING # in $dblibdir for details. # sub usage { print <getopt) { $ch = $dbopts->opt; if ($ch eq 'C') { $elem_separator = $dbopts->optarg; } elsif ($ch eq 'e') { $null_value = $dbopts->optarg; } else { &usage; }; }; &usage if ($#ARGV != 0); &readprocess_header; &write_header; my $colf = $colnametonum{$ARGV[0]}; die ("$prog: unknown column ``$ARGV[0]''.\n") if (!defined($colf)); while () { &pass_comments && next; &split_cols; my(@subf) = split(/$elem_separator/, $f[$colf]); push @subf, $null_value if ($#subf == -1 && defined($null_value)); foreach (@subf) { if (!defined($_) || $_ eq '') { next if (!defined($null_value)); $_ = $null_value; }; $f[$colf] = $_; &write_cols; }; }; print "# | $prog ", join(" ", @orig_argv), "\n"; exit 0;