3 # fi-keyline - Substracts parameters from an arbitrary file and writes them
4 # to gpivrc. Initially used for substarcting parameters from a
5 # README doc, containing description of experiments.
7 # Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008
8 # Gerber van der Graaf <gerber_graaf@users.sourceforge.net
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2, or (at your option)
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write to the Free Software Foundation,
22 # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #------------------------------------------------------------------
26 $VERSION = q
$Id: fi
-keyline
.pl
,v
1.4 2006-03-04 12:37:08 gerber Exp
$;
27 $HELP = "Filters each line that starts with a keyword";
28 $USAGE = "gpiv_fi-keyline [-h|-help] [-p|-print] [-v|-version]
29 [-if|input_file] [-of|output_file] keyword
33 -p: prints process parameters/variables to stdout
40 #-n: suppresses real execution
41 #-p: prints process parameters/variables to stdout
44 #----------------- Command line arguments handling ----------
55 'if|input_file=s' => \
$infile,
56 'of|output_file=s' => \
$outfile,
70 printf ("\nUsage: $USAGE\n");
74 $keyword = shift (@ARGV);
76 #-------------------------------------
78 if ($opt_p) {printf("input file = $infile\n");}
79 open (STDIN
, "$infile") || die 'can\'t open $infile';
83 if ($opt_p) {printf("output file = $outfile\n");}
84 open (STDOUT
, ">$outfile") || die 'can\'t open $outfile';
93 if ($_ ne "" && (!/^(\#|;)/)) { #skip blank lines, # or ; signs at first col
95 s/^ *//; #removes eventually leading space
96 @words = split(/ /, $_); #splitting line $_ up in words
97 #same as @words = split
98 if ($words[0] =~ $keyword) {
101 printf(STDOUT
"@words\n");
111 if ($infile) {close (STDIN
) || die 'can\'t close $infile';}
112 if ($outfile) {close (STDOUT
) || die 'can\'t close $infile';}