#!/usr/bin/perl -w # yc.pl # pod at tail use strict; use vars qw( @lc @uc @lcfirst @ucfirst ); my $infile = shift or die "\nUsage:yc.pl text_file_name\n"; my %outfile = ( lc => 'ylc.txt', uc => 'yuc.txt', lcf => 'ylcf.txt', ucf => 'yucf.txt', ); # read input data open (IN, "< $infile") or die "Can't open $infile for read: $!"; my @in = ; close IN or die "Cannot close $infile: $!"; for(@in) { chomp; # case-munging my $lc = lc(); my $uc = uc(); my $ucfirst = ucfirst($lc); my $lcfirst = lcfirst($uc); # print individual elements to console print "$_\n"; print "$lc\n"; print "$uc\n"; print "$lcfirst\n"; print "$ucfirst\n"; print "\n"; # populate lists of complete lines push @lc, $lc; push @uc, $uc; push @ucfirst, $ucfirst; push @lcfirst, $lcfirst; } # print to outfiles open (OUTLC, "> $outfile{lc}") or die "Can't open $outfile{lc} for write: $!"; open (OUTUC, "> $outfile{uc}") or die "Can't open $outfile{uc} for write: $!"; open (OUTLCF, "> $outfile{lcf}") or die "Can't open $outfile{lcf} for write: $!"; open (OUTUCF, "> $outfile{ucf}") or die "Can't open $outfile{ucf} for write: $!"; # for(@in) { print; } print "\n"; for(@lc) { print OUTLC; } for(@uc) { print OUTUC; } for(@lcfirst) { print OUTLCF; } for(@ucfirst) { print OUTUCF; } close OUTLC or die "Cannot close $outfile{lc}: $!"; close OUTUC or die "Cannot close $outfile{uc}: $!"; close OUTLCF or die "Cannot close $outfile{lcf}: $!"; close OUTUCF or die "Cannot close $outfile{ucf}: $!"; =pod =head1 Name yc.pl =head1 Synopsis yc.pl text_file_name Useless and rudimentary scriptlet from playing around with lc. Accepts input filename from command-line, and outputs to 4 files the same text but all uppercase, all lowercase, first letter lowercase, and first letter uppercase. I'll long remember lc's lessons on return value and context. {grin} "Useless use of lc in void context..." for trying to do this: for(@in) { lc(); print; } This is the part where you say, "And he's Saint(10) because???" ;^D =head1 Author ybiC =head1 Updated 2001-07-25 11:05 CDT Corrected couple o'tyops. Specify input file from command-line. Output to separate files instead of console. 2001-07-24 20:30 CDT Post to Perl Monks snippets. Initial working code. =head1 Todos LoL to streamline repetitive code of for/prints at tail. =head1 Tested ActivePerl 5.6 Win2kPro Perl 5.6 Cygwin Perl 5.00503 Debian 2.2r3 =cut