A barely useful yet quite rudimentary scriptlet from playing around with perlfunc: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
#!/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 = <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 w +rite: $!"; open (OUTUC, "> $outfile{uc}") or die "Can't open $outfile{uc} for w +rite: $!"; 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

In reply to (code) I Rest My Case (and this time I mean it) by ybiC

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.