Debian Codegraph @

template

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 #!/usr/bin/perl -w
2
3 # template: This is the default template file used to create
4 # new files.
5 #
6 # Copyright (C) 2002-2004 Suso Banderas
7
8 # This program is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU General Public License
10 # as published by the Free Software Foundation; either version 2
11 # of the License, or (at your option) any later version.
12 #
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 #
22 # You may contact the author at <[email protected]>.
23
24 #######################
25 # VARIABLES AND SETUP #
26 #######################
27
28 use Getopt::Std;
29 use strict;
30 use vars qw/ %opts $verbose /;
31
32 getopts('hdV', \%opts);
33
34 if ($opts{'h'}) {
35 &help();
36 exit(0);
37 }
38
39 if ($opts{'d'}) {
40 $verbose = 3;
41 print STDERR "Debug mode\n";
42 } elsif ($opts{'V'}) {
43 $verbose = 2;
44 print STDERR "Verbose mode\n";
45 } elsif ($opts{'q'}) {
46 $verbose = 0; # Nothing except the final answer
47 } else {
48 $verbose = 1; # Normal warnings and such.
49 }
50
51
52 ################
53 # MAIN PROGRAM #
54 ################
55
56 # For file args
57 if (@ARGV) {
58 foreach $file (@ARGV) {
59 print STDERR "Reading from file $file.\n" if ($verbose >= 2);
60 open (ARGFILE, "$file") &&
61 process_filehandle(\*ARGFILE, \@number_array) ||
62 $verbose && warn "Couldn't open file $file for reading: $!\n";
63 close (ARGFILE);
64 }
65 # For STDIN
66 } else {
67 print STDERR "Reading from STDIN.\n" if ($verbose >= 2);
68 process_filehandle(\*STDIN, \@number_array);
69 }
70
71
72 exit(0);
73
74 ###############
75 # SUBROUTINES #
76 ###############
77
78 sub help {
79 print <<"EOF";
80 ----------------------------------------------
81 template :
82 ----------------------------------------------
83 Usage:
84
85 template [options] <file>
86 | template [options]
87 template [options]
88
89 Options:
90 -d Debug. For developers only.
91 -h Help: You're looking at it.
92 -V Increase verbosity.
93 EOF
94 }
95
96 sub process_filehandle {
97 my $filehandle = shift;
98 my $number_array_ref = shift;
99
100 while (<$filehandle>) {
101 if (m/^\s*(\-?[0-9]*\.?[0-9]+)/) {
102 print STDERR "found number: $1\n" if ($verbose >= 3);
103 push(@$number_array_ref, $1);
104 }
105 }
106 return 1;
107 }
108
109
110 # Lay down some of that perl pod action.
111 =pod
112
113 =head1 NAME
114
115 template - template program file
116
117 =head1 SYNOPSIS
118
119 B<template> [-dhV] <FILE>
120
121 | B<template> [-dhV] (Input on STDIN from pipeline.)
122
123 B<template> [-dhV] (Input on STDIN. Use Ctrl-D to stop.)
124
125 =head1 DESCRIPTION
126
127 B<template> is a program that is part of the numeric utilities package. B<template>
128 will .......
129
130 =head1 OPTIONS
131
132 -h Help: You're looking at it.
133 -V Increase verbosity.
134 -d Debug mode. For developers
135
136
137 =head1 SEE ALSO
138
139 average(1), bound(1), interval(1), normalize(1), numgrep(1), numprocess(1), numsum(1), random(1), range(1), round(1)
140
141 =head1 COPYRIGHT
142
143 template is part of the num-utils package, which is copyrighted by
144 Suso Banderas and released under the GPL license. Please read
145 the COPYING and LICENSE files that came with the num-utils package
146
147 Developers can read the GOALS file and contact me about providing
148 submitions or help for the project.
149
150 =head1 MORE INFO
151
152 More info on template can be found at:
153
154 =over 1
155
156 =item B<http://suso.suso.org/programs/num-utils/>
157
158 =back
159
160 =cut
161