#!/usr/bin/perl -w use strict; unless ($ARGV[0] eq '-lc' || $ARGV[0] eq '-uc' ){ die "usage: lcuc [-uc | -lc] file\n"; } my $op = substr(shift @ARGV, 1, 2); while(<>){ no strict 'refs'; print &{$op}($_) } sub lc{ lc shift } sub uc{ uc shift } #### #!/usr/bin/perl -w use strict; my %ops = ( 'lc' => sub {lc shift }, 'uc' => sub {uc shift }, ); my $case = shift @ARGV; unless (exists $ops{$case}){ die "usage: lcuc [", join(' | ', keys %ops), "] file\n"; } while(<>){ print $ops{$case}->($_); }