Perl Unclassified Changing text case utility

Source Code Snippet (edit)

#!/usr/bin/perl -w
use strict;
use 5.010;

my ($type, $string);

print "What type of case? (upper/lower):
";
while (<STDIN>) {
	chomp;
	if (/^(upper|lower)$/i) {
		$type = $_;
		last;
	} else {
		print "Invalid type please type upper or lower:
";
	}
}

print "Please enter your text:
";
chomp($string = <STDIN>);
given ($type) {
	when ("upper") { print "U$string" }
	when ("lower") { print "L$string" }
}

print "
";
    
comments powered by Disqus

Last Source Code Snippets in same category

Perl Table creation/Postal addresses

Perl Unclassified2012-09-13 - sql

Perl Walk a directory/Recursively

Perl Unclassified2012-09-13 -

Perl Time a function

Perl Unclassified2012-09-13 - shift

Perl XML/XPath

Perl Unclassified2012-09-13 -

Perl Stack

Perl Unclassified2012-09-13 -

Perl Stem-and-leaf plot

Perl Unclassified2012-09-13 -