Revisiting Perl

As I wrote in a previous blog post, I did indeed dig out my Programming Perl book over the weekend and pulled out this particular solution. I’m sure there are other Perl solutions that are much more elegant and much shorter, but give me a break, ok? It’s been a while.

#! usr/bin/perl -w
$file = $ARGV[0];
$output = “new$file”; 
open (FH, “$file”) or die $!;
open (FH1, “>$output”) or die $!;
while(my $line = <FH>) {
    $op = lc($line);
    print FH1 $op;
close FH;
close FH1;

What is your Perl solution?

Edit: After Googling for a solution, I found the following on the interwebs:

perl -wpl -e ‘s/^.*$/U$&/g;’ filename

How’s that for small?

Leave a Reply