#!/usr/bin/perl our $type ||= shift or die "no type"; while( <> ) { if ( $type eq 'letters' ) { print if $_ =~ /[[:alpha:]]/; } elsif ( $type eq 'numbers' ) { print if $_ =~ /\d/; } else { print "bad type: $type" } }