Changeset 19dfa5c for app/src/gph
- Timestamp:
- 04/24/08 12:36:13 (17 years ago)
- Branches:
- master, help
- Children:
- 12d8443
- Parents:
- a5fdde9
- git-author:
- pawelk <pawelk@…> (04/24/08 12:36:13)
- git-committer:
- pawelk <pawelk@…> (04/24/08 12:36:13)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
app/src/gph/gph
rcfed5c1 r19dfa5c 8 8 use strict; 9 9 use Getopt::Long; 10 use File::HomeDir; 10 11 11 my @process; 12 13 14 15 16 my $systemconfigfile='/usr/local/etc/utt/gph.conf'; 17 my $userconfigfile=home()."/.utt/gph.conf"; 18 19 Getopt::Long::Configure('no_ignore_case_always'); 20 12 21 my $help=0; 22 my $inputfile=0; 23 my $outputfile=0; 24 my @process=(); 13 25 my $reset; 14 my $interactive=1; 26 my $interactive=0; 27 28 #read configuration files########################### 29 my $file; 30 my @process_conf=(); 31 foreach $file ($systemconfigfile, $userconfigfile){ 32 if(open(CONFIG, $file)){ 33 while (<CONFIG>) { 34 chomp; 35 s/#.*//; 36 s/^\s+//; 37 s/\s+$//; 38 next unless length; 39 my ($name, $value) = split(/\s*=\s*/, $_, 2); 40 if(($name eq "inputfile")or($name eq "f")){ 41 $inputfile=$value; 42 } 43 elsif(($name eq "outputfile")or($name eq "o")){ 44 $outputfile=$value; 45 } 46 elsif(($name eq "process")or($name eq "p")){ 47 push @process_conf, $value; 48 } 49 elsif(($name eq "reset")or($name eq "r")){ 50 $reset=$value; 51 } 52 elsif(($name eq "interactive")or($name eq "i")){ 53 $interactive=1; 54 } 55 elsif(($name eq "help")or($name eq "h")){ 56 $help=1; 57 } 58 59 } 60 close CONFIG; 61 } 62 } 63 ######################################################### 64 65 15 66 16 67 GetOptions("process|p=s" => \@process, 68 "inputfile|f=s" => \$inputfile, 69 "outputfile|o=s" => \$outputfile, 17 70 "help|h" => \$help, 18 71 "reset|r=s" => \$reset, 19 72 "interactive|i" => \$interactive); 73 74 @process = @process_conf if @process<1; 20 75 21 76 if($help) … … 27 82 -p tag Process segments with this tag as nodes. 28 83 -r tag Start new graph at this tag. 29 -f filename Input file (NIE DZIALA).30 -o filename Output file (NIE DZIALA).31 -i Toggle interactive mode (default=o n).84 -f filename Input file. 85 -o filename Output file. 86 -i Toggle interactive mode (default=off). 32 87 END 33 88 ; … … 38 93 $|=1 if $interactive; 39 94 95 96 if(!$inputfile or $inputfile eq "-") { 97 *INPUT = *STDIN; 98 } 99 else { 100 open(INPUT, "$inputfile") or die("Can't open input file: $inputfile!"); 101 } 102 103 if(!$outputfile or $outputfile eq "-") { 104 *OUTPUT = *STDOUT; 105 } 106 else { 107 open(OUTPUT, "$outputfile") or die("Can't open output file: $outputfile!"); 108 } 109 40 110 my @prev; 41 42 111 my $n=0; 43 112 44 while(< >)113 while(<INPUT>) 45 114 { 46 115 chomp; … … 89 158 } 90 159 91 print $_.$gph."\n";160 print OUTPUT $_.$gph."\n"; 92 161 } 93 162
Note: See TracChangeset
for help on using the changeset viewer.