The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 06:57 PM
UNIX command to reverese lower and upper case rfourn Shell Programming and Scripting 6 12-07-2007 10:33 PM
Converting file names to upper case Sabari Nath S Shell Programming and Scripting 5 01-12-2006 01:38 PM
lower case to upper case string conversion in shell script dchalavadi UNIX for Dummies Questions & Answers 3 05-29-2002 12:07 AM
Upper And Lower Case pciatto Shell Programming and Scripting 1 04-29-2002 12:17 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-18-2008
doubleminus doubleminus is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 27
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!
  #2 (permalink)  
Old 05-18-2008
FlyingSquirrel FlyingSquirrel is offline
Registered User
  
 

Join Date: May 2008
Posts: 38
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.
  #3 (permalink)  
Old 05-19-2008
doubleminus doubleminus is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 27
Perfect, exactly what I needed. Great learning experience. Thank you.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:17 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0