home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2000 February
/
PCWorld_2000-02_cd.bin
/
live
/
usr
/
X11R6
/
bin
/
capitalize
< prev
next >
Wrap
Text File
|
1998-11-18
|
555b
|
28 lines
#!/usr/bin/perl --
# Free replacement for Sun's capitalize as required by Openwin's
# text_extras_menu.
#
# Copyright (C) 1998 by Martin Buck <mbuck@debian.org>
# Licensed under the GNU General Public License
sub usage {
die "Usage: $0 -u|-l|-c\n";
}
usage if ($#ARGV != 0);
if ($ARGV[0] eq "-u") {
$capitalize = sub { s/(.)/\u$1/g };
} elsif ($ARGV[0] eq "-l") {
$capitalize = sub { s/(.)/\l$1/g };
} elsif ($ARGV[0] eq "-c") {
$capitalize = sub { s/(^| |\t)(.)/$1\u$2/g };
} else {
usage;
}
while (<STDIN>) {
&$capitalize;
print $_;
}