uppercase strings
I would appreciate some help with this. I am learning Perl. I have a string inputed by the user. This string is then split, every first letter of each word in the string is uppercased, then joined back together and printed. Here is my code, can anyone help? Thanks, Sara G. !/usr/bin/perl # Demonstrating split and join when prompting the user for input and then changing the first letter of each word in a sentence to uppercase. use strict; print Please enter a sentence of your choice\n; my $firstline = STDIN; chomp ( $firstline ); my @words = split( / /, $firstline ); print $_\n foreach ( @words ); $firstline = join( ' ', @words ); # joins the string back together and prints it. print $firstline\n; __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: uppercase strings
On Oct 8, Sara Gribble said: I would appreciate some help with this. I am learning Perl. I have a string inputed by the user. This string is then split, every first letter of each word in the string is uppercased, then joined back together and printed. my @words = split( / /, $firstline ); print $_\n foreach ( @words ); What you need to do goes here. There are many ways to make the first character of a string in an array of strings uppercase. Here is one way: foreach (@words) { $_ = ucfirst } $firstline = join( ' ', @words ); # joins the string print $firstline\n; Read 'perldoc -f ucfirst' for more details. -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ stu what does y/// stand for? tenderpuss why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: uppercase strings
Looks like you are almost there... % perldoc -f ucfirst On Thu, 2003-10-09 at 13:41, Sara Gribble wrote: I would appreciate some help with this. I am learning Perl. I have a string inputed by the user. This string is then split, every first letter of each word in the string is uppercased, then joined back together and printed. Here is my code, can anyone help? Thanks, Sara G. !/usr/bin/perl # Demonstrating split and join when prompting the user for input and then changing the first letter of each word in a sentence to uppercase. use strict; print Please enter a sentence of your choice\n; my $firstline = STDIN; chomp ( $firstline ); my @words = split( / /, $firstline ); print $_\n foreach ( @words ); $firstline = join( ' ', @words ); # joins the string back together and prints it. print $firstline\n; __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]