3 #=======================================================================
5 # Mixes the letters in words, except the first and last letter. Just an
9 # ©opyleft 2006– Øyvind A. Holm <sunny@sunbase.org>
10 # License: GNU General Public License, see end of file for legal stuff.
11 #=======================================================================
29 $progname =~ s
#^.*/(.*?)$#$1#;
32 my $id_date = $rcs_id;
33 $id_date =~ s/^.*?\d+ (\d\d\d\d-.*?\d\d:\d\d:\d\d\S+).*/$1/;
35 Getopt
::Long
::Configure
("bundling");
37 "debug" => \
$Opt{'debug'},
38 "help|h" => \
$Opt{'help'},
39 "version" => \
$Opt{'version'},
40 "xml|x" => \
$Opt{'xml'}
41 ) || die("$progname: Option error. Use -h for help.\n");
43 $Opt{'debug'} && ($Debug = 1);
44 $Opt{'help'} && usage
(0);
45 $Opt{'version'} && print_version
();
48 s/(\W?\w)(\w{2,})(\w\W?)/join("", $1, mix_word($2), $3)/ge;
54 D
("mix_word(\"$Word\")");
55 my @Array = split(//, $Word);
56 D
("Array = (\"" . join("\", \"", @Array) . "\")");
58 return(join("", @Array));
64 D
("mix_array(\"$array\")");
66 for ($i = @
$array; --$i; ) {
67 my $j = int rand ($i+1);
69 @
$array[$i,$j] = @
$array[$j,$i];
75 # Print program version {{{
76 xml_print
("$rcs_id\n");
82 # Print out some text, using DocBook if --xml is specified {{{
84 my ($xml_start, $xml_end) =
89 <?xml version="1.0" encoding="UTF-8"?>
90 <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4//EN" "http://docbook.org/xml/4.3/docbookx.dtd">
102 $Opt{'xml'} ? txt_to_xml
($Txt) : "\n$Txt\n",
109 # Send the help message to stdout {{{
115 Mixes the letters in words, except the first and last letter. Just an
118 Usage: $progname [options] [file [files [...]]]
125 Print version information.
129 Print debugging messages.
136 # Print a debugging message {{{
138 my @call_info = caller;
139 chomp(my $Txt = shift);
140 my $File = $call_info[1];
142 $File =~ s
#^.*/(.*?)$#$1#;
144 printf(STDERR
"<debug> <pid>%s</pid> <file>%s</file> <line>%s</line> <msg>%s</msg> </debug>\n",
147 txt_to_xml
($call_info[2]),
151 print(STDERR
"$File:$call_info[2] $$ $Txt\n");
158 # Return a XML-safe version of a string {{{
161 $Txt =~ s/&/&/gs;
170 # Plain Old Documentation (POD) {{{
184 mixword [options] [file [files [...]]]
188 Mixes the letters in words, except the first and last letter. Just an
195 =item B<-h>, B<--help>
197 Print a brief help summary.
201 Print version information.
203 =item B<-x>, B<--xml>
209 Print debugging messages.
219 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
223 Copyleft © Øyvind A. Holm <sunny@sunbase.org>
224 This is free software; see the file F<COPYING> for legalese stuff.
228 This program is free software; you can redistribute it and/or modify it
229 under the terms of the GNU General Public License as published by the
230 Free Software Foundation; either version 2 of the License, or (at your
231 option) any later version.
233 This program is distributed in the hope that it will be useful, but
234 WITHOUT ANY WARRANTY; without even the implied warranty of
235 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
236 See the GNU General Public License for more details.
238 You should have received a copy of the GNU General Public License along
239 with this program; if not, write to the Free Software Foundation, Inc.,
240 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
248 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :