3 #=======================================================================
5 # File ID: 76d291aa-f744-11dd-9dc1-000475e441b9
9 # ©opyleft 2008– Øyvind A. Holm <sunny@sunbase.org>
10 # License: GNU General Public License version 2 or later, see end of
11 # file for legal stuff.
12 #=======================================================================
34 $progname =~ s/^.*\/(.*?)$/$1/;
35 our $VERSION = "0.00";
37 Getopt
::Long
::Configure
("bundling");
40 "char|c=o" => \
$Opt{'char'},
41 "count|n=i" => \
$Opt{'count'},
42 "debug" => \
$Opt{'debug'},
43 "help|h" => \
$Opt{'help'},
44 "verbose|v+" => \
$Opt{'verbose'},
45 "version" => \
$Opt{'version'},
47 ) || die("$progname: Option error. Use -h for help.\n");
49 $Opt{'debug'} && ($Debug = 1);
50 $Opt{'help'} && usage
(0);
51 if ($Opt{'version'}) {
56 if ($Opt{'char'} < 0 || $Opt{'char'} > 255) {
57 die("$progname: $Opt{'char'}: Invalid character value\n");
60 my $Count = $Opt{'count'};
62 die("$progname: Has to specify --count option " .
63 "with a value greater than 0\n");
64 my $curr_count = $Count + 1;
66 $/ = chr($Opt{'char'});
73 if ($curr_count >= $Count) {
74 $File = sprintf("%08x", $file_count);
75 if (open(FP
, ">$File")) {
78 msg
(1, "Creating $File");
80 die("$progname: $File: Cannot create file: $!\n");
88 # Print program version {{{
89 print("$progname v$VERSION\n");
94 # Send the help message to stdout {{{
97 if ($Opt{'verbose'}) {
103 Split a stream separated by a special character into files.
105 Usage: $progname [options] [file [files [...]]]
110 Use character with value x as separator. Default: 0.
112 Store x records in every file.
116 Increase level of verbosity. Can be repeated.
118 Print version information.
120 Print debugging messages.
128 # Print a status message to stderr based on verbosity level {{{
129 my ($verbose_level, $Txt) = @_;
131 if ($Opt{'verbose'} >= $verbose_level) {
132 print(STDERR
"$progname: $Txt\n");
138 # Print a debugging message {{{
140 my @call_info = caller;
141 chomp(my $Txt = shift);
142 my $File = $call_info[1];
144 $File =~ s
#^.*/(.*?)$#$1#;
145 print(STDERR
"$File:$call_info[2] $$ $Txt\n");
152 # Plain Old Documentation (POD) {{{
162 [options] [file [files [...]]]
172 =item B<-h>, B<--help>
174 Print a brief help summary.
176 =item B<-v>, B<--verbose>
178 Increase level of verbosity. Can be repeated.
182 Print version information.
186 Print debugging messages.
196 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
200 Copyleft © Øyvind A. Holm E<lt>sunny@sunbase.orgE<gt>
201 This is free software; see the file F<COPYING> for legalese stuff.
205 This program is free software: you can redistribute it and/or modify it
206 under the terms of the GNU General Public License as published by the
207 Free Software Foundation, either version 2 of the License, or (at your
208 option) any later version.
210 This program is distributed in the hope that it will be useful, but
211 WITHOUT ANY WARRANTY; without even the implied warranty of
212 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
213 See the GNU General Public License for more details.
215 You should have received a copy of the GNU General Public License along
217 If not, see L<http://www.gnu.org/licenses/>.
225 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :