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

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s