hi guys,i have this problem.first let me show you the so far code -
#!/user/bin/perl
-
while ($a = <STDIN>)
-
{
-
if ($a =~ tr/A-Z/a-z/)
-
{
-
print "$a\n";
-
}
-
if ($a =~ tr/a-z/A-Z/)
-
{
-
print "the uppercase is $a\n";
-
}
-
-
elsif ($a =~ tr/[A-Z]/[a-z]/)
-
{
-
$b=$a;
-
$b =~ tr/A-Z/a-z/c;
-
print "$b\n";
-
}
-
}
-
i got the conversion of uppercase to lowercase and vice verse,
but,the problem is i want the first letter of the output in uppercase and remaining in lowercase.
9 4832
Hi
for getting the first letter in upper case or lowercase,u have to use ^
like this
$x=~s/^[A-Z]/[a-z]/;
hi guys,i have this problem.first let me show you the so far code -
#!/user/bin/perl
-
while ($a = <STDIN>)
-
{
-
if ($a =~ tr/A-Z/a-z/)
-
{
-
print "$a\n";
-
}
-
if ($a =~ tr/a-z/A-Z/)
-
{
-
print "the uppercase is $a\n";
-
}
-
-
elsif ($a =~ tr/[A-Z]/[a-z]/)
-
{
-
$b=$a;
-
$b =~ tr/A-Z/a-z/c;
-
print "$b\n";
-
}
-
}
-
i got the conversion of uppercase to lowercase and vice verse,
but,the problem is i want the first letter of the output in uppercase and remaining in lowercase.
Hi
for getting the first letter in upper case or lowercase,u have to use ^
like this
$x=~s/^[A-Z]/[a-z]/;
That is not true, but it is an option that might apply to a particular situation. (Your example will convert the very first letter of a string into lower-case). But that may or may not be what humaid is trying to do. But since humaid has not replied to the question we may never know.
That is not true, but it is an option that might apply to a particular situation. (Your example will convert the very first letter of a string into lower-case). But that may or may not be what humaid is trying to do. But since humaid has not replied to the question we may never know.
hi guys,the problem is,suppose i give the input as,
hi this is humaid
i want the output as:Hi This Is Humaid
this is what iam trying.
hi guys,the problem is,suppose i give the input as,
hi this is humaid
i want the output as:Hi This Is Humaid
this is what iam trying.
The following does what you want: -
use strict;
-
use warnings;
-
-
my $phrase = "this is nobody.";
-
-
print("Unmodified phrase: $phrase\n");
-
-
my @split_phrase = split(/\s/, $phrase);
-
-
my @new_phrase;
-
my $var1;
-
-
-
foreach my $word (@split_phrase)
-
{
-
chomp($word);
-
$var1 = ucfirst $word;
-
push(@new_phrase, $var1);
-
}
-
-
print("@new_phrase");
-
Regards,
Jeff
-
use strict;
-
use warnings;
-
my $phrase = "this is nobody.";
-
$phrase =~ s/(\w+)/ucfirst($1)/eg;
-
print $phrase;
-
-
use strict;
-
use warnings;
-
my $phrase = "this is nobody.";
-
$phrase =~ s/(\w+)/ucfirst($1)/eg;
-
print $phrase;
-
Sure, one-up me. I see how you are! ;-|)
See, this is Perl. Just another example that TIMTOWTDI.
Regards,
Jeff
Sure, one-up me. I see how you are! ;-|)
See, this is Perl. Just another example that TIMTOWTDI.
Regards,
Jeff
naaaaa.....not one-up-manship. I wasn't going to post code but since code has been posted I figured I'd throw my 2 cents in. humaid can decide what is best for his situation.
BTW.... have you "seen" Miller lately?
naaaaa.....not one-up-manship. I wasn't going to post code but since code has been posted I figured I'd throw my 2 cents in. humaid can decide what is best for his situation.
BTW.... have you "seen" Miller lately?
No worries, I was just bustin. Nice way of doing it. I like learning the shortcuts.
As a matter of fact, no, I have not seen our other Moderator around at all and was beginning to wonder if he has dropped off the face of the {forum|earth}. Hopefully he will apparate soon to say hello.
Regards,
Jeff
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Hallvard B Furuseth |
last post by:
Has someone got a Python routine or module which converts Unicode
strings to lowercase (or uppercase)?
What I actually need to do is to compare a number of strings in a
case-insensitive manner,...
|
by: Markus Dehmann |
last post by:
My ios::uppercase (and others) seems not to work.
#include <iostream>
using namespace std;
int main(){
int num = 45;
cout.setf(ios::hex | ios::showbase | ios::uppercase);
cout << "number " <<...
|
by: The_Kingpin |
last post by:
Hi all, I need to make a function that convert a string into a certain
format. Here what are the restriction:
-The first letter of the first and last name must be uppercase.
-If a first name...
|
by: BSHELTON |
last post by:
How do I convert existing lowercase data to uppercase in Access 2000? I used the following which did not work?
UPDATE HousingTowns
SET tMunis=UPPER(tMunis);
"HousingTowns" is the table name....
|
by: t8ntboy |
last post by:
I have a table the contains field called PersonID. Each record in the
personID field begins with the letter "p" in uppercase or lowercase. I
want to run a query that finds all of the lowercase...
|
by: titan nyquist |
last post by:
Why does ToTitleCase not work if the case is already in upper case?
I have to make my string lowercase, first, before I pass to to
ToTitleCase to have it work.
Titan
|
by: jerger |
last post by:
i have a great program now with the help of a member from this site, but i need a little customization to meet the needs of non-english speakers... who might accidendtly type punctuation which would...
|
by: tom harrison |
last post by:
i'm so glad i found this forum! i have to have some coursework done by the end of the week and i really need it explaining to me. i'm not really that big on stuff like this but it's a part of my web...
|
by: cpptutor2000 |
last post by:
Could some C guru provide some hints on my problem? I am trying to
sort an array of character strings, where each string contains
lowercase, uppercase, digits as well as non-alphanumeric characters...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |