The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Accepting Upper and Lower case lweegp Shell Programming and Scripting 8 12-08-2007 02:57 PM
UNIX command to reverese lower and upper case rfourn Shell Programming and Scripting 6 12-07-2007 06:33 PM
Converting file names to upper case Sabari Nath S Shell Programming and Scripting 5 01-12-2006 09:38 AM
lower case to upper case string conversion in shell script dchalavadi UNIX for Dummies Questions & Answers 3 05-28-2002 09:07 PM
Upper And Lower Case pciatto Shell Programming and Scripting 1 04-29-2002 09:17 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-18-2008
Registered User
 

Join Date: Apr 2008
Posts: 25
Stumble this Post!
Perl - converting selected characters to upper/lower case

Using STDIN, how can I use perl to take an input string, with all lower case letters in the first five characters, and convert them to uppercase...

then take all uppercase letters in the second five characters and convert them to lowercase.

Example:
MichaelSmith to michaELSMIth

Thank you!
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 05-18-2008
Registered User
 

Join Date: May 2008
Posts: 8
Stumble this Post!
doubleminus,

try this...

#!/usr/bin/perl
$str = <STDIN>;
chomp $str;
print lc(substr($str, 0,5)) . uc(substr($str, 5, 5)) . substr($str, 10) . "\n";

Enter in
MichaelSmith

It lowercases the first 5 chars, concatenated to the uppercase of the next 5 characters, concatenated to the remaining characters, concatenated to a newline char.
Reply With Quote
  #3 (permalink)  
Old 05-18-2008
Registered User
 

Join Date: Apr 2008
Posts: 25
Stumble this Post!
Perfect, exactly what I needed. Great learning experience. Thank you.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 12:46 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0