installed_progs.t: Python checks stdout too, 150 ok
[sunny256-utils.git] / find_8bit
blob9b4b9d36a43e29228539f55b011d66736861b9f5
1 #!/usr/bin/env perl
3 #=======================================================================
4 # find_8bit
5 # File ID: 292fa714-5d3a-11df-83e3-90e6ba3022ac
7 # Lister ut linjer med 8-bits tegn
9 # Character set: UTF-8
10 # ©opyleft STDyearDTS– Øyvind A. Holm <sunny@sunbase.org>
11 # License: GNU General Public License version 2 or later, see end of
12 # file for legal stuff.
13 #=======================================================================
15 use strict;
16 use warnings;
17 use Getopt::Long;
19 local $| = 1;
21 our %Opt = (
23 'help' => 0,
24 'quiet' => 0,
25 'verbose' => 0,
26 'version' => 0,
30 our $progname = $0;
31 $progname =~ s/^.*\/(.*?)$/$1/;
32 our $VERSION = '0.1.0';
34 Getopt::Long::Configure('bundling');
35 GetOptions(
37 'help|h' => \$Opt{'help'},
38 'quiet|q+' => \$Opt{'quiet'},
39 'verbose|v+' => \$Opt{'verbose'},
40 'version' => \$Opt{'version'},
42 ) || die("$progname: Option error. Use -h for help.\n");
44 $Opt{'verbose'} -= $Opt{'quiet'};
45 $Opt{'help'} && usage(0);
46 if ($Opt{'version'}) {
47 print_version();
48 exit(0);
51 exit(main());
53 sub main {
54 # {{{
55 my $Retval = 0;
57 while (<>) {
58 /[\x80-\xFF]/ && print;
61 return $Retval;
62 # }}}
63 } # main()
65 sub print_version {
66 # Print program version {{{
67 print("$progname $VERSION\n");
68 return;
69 # }}}
70 } # print_version()
72 sub usage {
73 # Send the help message to stdout {{{
74 my $Retval = shift;
76 if ($Opt{'verbose'}) {
77 print("\n");
78 print_version();
80 print(<<"END");
82 Usage: $progname [options] [file [files [...]]]
84 Options:
86 -h, --help
87 Show this help.
88 -q, --quiet
89 Be more quiet. Can be repeated to increase silence.
90 -v, --verbose
91 Increase level of verbosity. Can be repeated.
92 --version
93 Print version information.
95 END
96 exit($Retval);
97 # }}}
98 } # usage()
100 sub msg {
101 # Print a status message to stderr based on verbosity level {{{
102 my ($verbose_level, $Txt) = @_;
104 if ($Opt{'verbose'} >= $verbose_level) {
105 print(STDERR "$progname: $Txt\n");
107 return;
108 # }}}
109 } # msg()
111 __END__
113 # This program is free software; you can redistribute it and/or modify
114 # it under the terms of the GNU General Public License as published by
115 # the Free Software Foundation; either version 2 of the License, or (at
116 # your option) any later version.
118 # This program is distributed in the hope that it will be useful, but
119 # WITHOUT ANY WARRANTY; without even the implied warranty of
120 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
121 # See the GNU General Public License for more details.
123 # You should have received a copy of the GNU General Public License
124 # along with this program.
125 # If not, see L<http://www.gnu.org/licenses/>.
127 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :